In case anyone needs these:
These are functions that produce a palm-format time (seconds since
whenever it is) from a more reasonable set of
info(year,month,day,hour,min,sec). i used it in my PC app that had to
produce palm PRCs with correct timestamps.
they both take the same params: year(0...),
month(1..12),day(1..31),hour(0..23),min(0..59),sec(0..59);
PALM_TIME is a function
PALM_TIME_CONST is a macro, that expands completely to a value if the
parameters are constants (eg a fixed date).
They are both independent of each other.
code follows:
UInt32 PALM_TIME(UInt32 _yr,UInt32 _mo,UInt32 _da,UInt32 _hr,UInt32
_mi,UInt32 _se){
const UInt16 daysInPrevMonths[] ={
0, 31, 60, 91,
121, 152,
182, 213, 244, 274,
305, 335,
366+0, 366+31, 366+59, 366+90, 366+120, 366+151,
366+181, 366+212, 366+243, 366+273,
366+304, 366+334,
731+0, 731+31, 731+59, 731+90, 731+120, 731+151,
731+181, 731+212, 731+243, 731+273,
731+304, 731+334,
1096+0, 1096+31, 1096+59, 1096+90,
1096+120,1096+151,
1096+181,1096+212,1096+243,1096+273,1096+304,1096+334,
1461
};
return ((((((UInt32) (_yr - 1904) / 4) * 1461) +
\
(daysInPrevMonths[(_yr % 4) * 12 + _mo - 1]) + \
_da - 1) * 0x15180) + (_hr * 3600) + (_mi * 60) + _se);
}
#define DAYS_IN_PRV_MNTHS(_i) ((_i == 0)?0:((_i == 1)?31:((_i ==
2)?60:((_i == 3)?91:((_i == 4)?121:((_i == 5)?152:((_i == 6)?182:((_i
== 7)?213:((_i == 8)?244:((_i == 9)?274:((_i == 10)?305:((_i ==
11)?335:((_i == 12)?366:((_i == 13)?397:((_i == 14)?425:((_i ==
15)?456:((_i == 16)?486:((_i == 17)?517:((_i == 18)?547:((_i ==
19)?578:((_i == 20)?609:((_i == 21)?639:((_i == 22)?670:((_i ==
23)?700:((_i == 24)?731:((_i == 25)?762:((_i == 26)?790:((_i ==
27)?821:((_i == 28)?851:((_i == 29)?882:((_i == 30)?912:((_i ==
31)?943:((_i == 32)?974:((_i == 33)?1004:((_i == 34)?1035:((_i ==
35)?1065:((_i == 36)?1096:((_i == 37)?1127:((_i == 38)?1155:((_i ==
39)?1186:((_i == 40)?1216:((_i == 41)?1247:((_i == 42)?1277:((_i ==
43)?1308:((_i == 44)?1339:((_i == 45)?1369:((_i == 46)?1400:((_i ==
47)?1430:((_i ==
48)?1461:(LinkError_InvalidDefineArrayIndex()))))))))))))))))))))))))))))))))))))))))))))))))))
#define PALM_TIME_CONST(_yr,_mo,_da,_hr,_mi,_se)
\
((((((UInt32) (_yr - 1904) / 4) * 1461) +
\
(DAYS_IN_PRV_MNTHS(((_yr % 4) * 12 + _mo - 1))) +
\
_da - 1) * 0x15180) + (_hr * 3600) + (_mi * 60) + _se)
--
----
Best Regards,
Dmitry Grinberg
(847) 226 9295
--
For information on using the ACCESS Developer Forums, or to unsubscribe, please
see http://www.access-company.com/developers/forums/