On Thu, Jan 03, 2002 at 05:56:00PM -0500, Dave Lippincott wrote:
> But if you're not using the DateTime structures on the Palm, the data will
> be just the 32 bit number (reversing bytes as necessary) representing
> seconds since 1/1/1904.  If you subtract the difference in seconds between
> 1/1/1904 and 1/1/1970, you could load the resulting number directly into
> your Windows date/time structure.

And if you're not using Windows or POSIX (e.g. you want to write in
portable ISO C), you're screwed because you don't know that your epoch
is 1970-01-01.  In ISO C, there might be no epoch at all because time_t
is not necessarily a seconds count.

> However, when you start playing around with seconds... Make sure you force
> Windows not to automatically compensate for your PC's time zone.

Right.  It's been a while since I looked at this, but when I wrote
similar code I came to the conclusion that it was impossible to do this
conversion using ISO C's date/time library functions.  (OTOH it *is*
possible using the timezone side effect of POSIX's localtime() function.)

Writing the code to do the conversion by hand is quite enjoyable; my
(GPLed) version is at

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/prc-tools/prc-tools/tools/pfdtime.c?rev=1.1&content-type=text/vnd.viewcvs-markup

Last I looked, both pilot-link and par still got the timezones wrong.

    John

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to