Guest User

Untitled

a guest
Jul 17th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.09 KB | None | 0 0
  1. CDateTime     a, b (2000, 2, 2, 0, 0, 0);
  2. istringstream is;
  3. bool          st;
  4.  
  5. b = "2011-03-01 14:50:20";
  6. a = "2011-12-30 21:08:14";
  7. cout << a; // 2011-12-30 21:08:14
  8. cout << a - b; // 26288274
  9. a = a + 259200;
  10. cout << a; // 2012-01-02 21:08:14
  11. is . clear ();
  12. is . str ( "2000-01-01 12:00:00" );
  13. is >> a; // is . fail () = false
  14. cout << a["year"]; // 2000
  15. cout << a["month"]; // 1
  16. cout << a["day"]; // 1
  17. cout << a["hour"]; // 12
  18. cout << a["min"]; // 0
  19. cout << a["sec"]; // 0
  20. st = a == b; // st = false
  21. st = a != b; // st = true
  22. st = a >= b; // st = false
  23. st = a <= b; // st = true
  24. st = a >  b; // st = false
  25. st = a <  b; // st = true
  26.  
  27. a = "2000-12-31 00:00:00";
  28. is . clear ();
  29. is . str ( "2010-13-27 00:00:00" );
  30. is >> a; // is . fail () = true
  31. is . clear ();
  32. is . str ( "2003-02-29 00:00:00" );
  33. is >> a; // is . fail () = true
  34. is . clear ();
  35. is . str ( "2004-2-29 1:2:3" );
  36. is >> a; // is . fail () = false
  37. is . clear ();
  38. is . str ( "1900-02-29 00:00:00" );
  39. is >> a; // is . fail () = true
  40. is . clear ();
  41. is . str ( "2000-02-29 00:00:00" );
  42. is >> a; // is . fail () = false
Add Comment
Please, Sign In to add comment