16 cout <<
"Universal CT: " << utc << endl;
17 cout <<
"User defined: " <<
Time::fmt(
"%Y=%m=%d %H=%M=%S.%f") << utc << endl;
18 cout <<
"SQL-format: " <<
Time::sql << utc << endl;
19 cout <<
"ISO-format: " <<
Time::iso << utc << endl;
25 str <<
"stringstream: " <<
Time::sql << utc;
26 cout << str.str() << endl;
30 const double mjd1 = utc.
Mjd();
31 cout <<
"Mjd: " <<
Time::sql << utc <<
" (" << mjd1 <<
")" << endl;
37 const double mjd2 = utc.Mjd();
40 cout <<
"Mjd: " <<
Time::sql << utc <<
" (" << mjd2 <<
")" << endl;
41 cout <<
"Diff: " << mjd1 - mjd2 << endl;
45 const Time bd(1974, 9, 9, 21, 59, 42, 123456);
48 cout <<
"Loc default: " <<
Time::def << bd << endl;
49 cout <<
"Standard: " <<
Time::std << bd << endl;
64 cout <<
"Stream: " << str.str() << endl;
70 cout << tm.Y() <<
" " << tm.M() <<
" " << tm.D() <<
" " ;
71 cout << tm.h() <<
" " << tm.m() <<
" " << tm.s() <<
" " ;
72 cout << tm.us() << endl;
76 const string s =
"2042-12-24 12:42:42";
80 cout <<
"String: " << s << endl;
81 cout <<
"TimeFromStr: " << tstr.
GetAsStr() << endl;
87 cout <<
"T0 = " << t0 << endl;
88 cout <<
"T1 = " << t1 << endl;
90 cout <<
"T1 += 4242h: " << t1 << endl;
92 cout <<
"T1 += 42min: " << t1 << endl;
94 cout <<
"T1 += 42sec: " << t1 << endl;
97 cout <<
"T1 - T0 = " << t1-t0 << endl;
99 const time_duration diff = t1-t0;
100 cout <<
"T1 - T0 = " << diff.total_seconds() <<
"sec" << endl;
static const _time_format sql
set to format to the iso standard
Adds some functionality to boost::posix_time::ptime for our needs.
static const _time_format iso
set to format to the sql format (without the fraction of seconds)
static const _time_format reset
static const _time_format ssql
set to format to the sql format
static const _time_format def
Remove the format description from the stream.
static const _time_format fmt(const char *txt=0)
A stream manipulator to set the output/input format.
void SetFromStr(const std::string &str, const char *fmt="%Y-%m-%d %H:%M:%S")
static const _time_format std
set to format to the locale default
Initialize with local time.
std::string GetAsStr(const char *fmt="%Y-%m-%d %H:%M:%S") const