1 posix_time
Boost: posix_time: ptime ptime1 = boost: posix_time: time_from_string (STD: string (str1 )));
Boost: posix_time: ptime ptime2 = boost: posix_time: time_from_string (STD: string (str2 )));
Determine equal functions
(Ptime1 = ptime2 )? True: false
Greaterthan Function
(Ptime1> ptime2 )? True: false
Lessthan Function
(Ptime1 <ptime2 )? True: false
When time1 = 00:00:00
Time2 = 2011-01-11
Test results:
Time1 and time2 are not equal
Time1 is not greater than time2
Time1 is smaller than time2
2 calculate the number of days of time difference
Date day1 = from_simple_string ("2001-10-9 ");
Date today = day_clock: local_day ();
Days days_limint = today-day1;
Struct stat stinfo;
Time_t tt;
Stat ("F: \ yuj \ test_env \ 11.txt", & stinfo );
Tt = stInfo. st_ctime;
Ptime pt = boost: posix_time: from_time_t (tt );
Date fileDate = pt. date ();
Days days_limint2 = fileDate-today;
Printf ("difference % d day \ n", days_limint.days ());
Printf ("difference % d day \ n", days_limint2.days ());