3 /// Conversion between time_t and cenmin_t and back.
4 /// time_t is the POSIX time, seconds from Jan 1, 1970
5 /// min1900_t is the minutes from Jan 1, 1900
9 Copyright (C) 2005-2006, Net Direct Inc. (http://www.netdirect.ca/)
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 See the GNU General Public License in the COPYING file at the
21 root directory of this project for more details.
34 using namespace Barry
;
36 void display(const char *msg
, time_t t
)
38 cout
<< msg
<< ": " << ctime(&t
);
39 cout
<< msg
<< " seconds: "
41 << "(0x" << setbase(16) << t
<< ")"
43 cout
<< msg
<< " minutes: "
44 << setbase(10) << (t
/60)
45 << "(0x" << setbase(16) << (t
/60) << ")"
50 void calc(const char *msg
, time_t t
, min1900_t dbval
)
53 display(" Initial time", t
);
54 display(" DB Val", min2time(dbval
));
62 // set to Oct 4, 2005, 2pm;
71 calc("Oct 4", t
, 0x0350c118);
75 min1900_t m
= time2min(t
);
76 time_t tc
= min2time(m
);
77 cout
<< "Original time: " << t
<< endl
;
78 cout
<< "time2min: " << m
<< endl
;
79 cout
<< "min2time: " << tc
<< endl
;
80 if( t
== (tc
+ t
% 60) )
81 cout
<< "Success! (orig == converted + mod)" << endl
;
83 cout
<< "Failed!" << endl
;