Thank's.
I needed this conversion on the Palm side - it would be straightforward on
the Windows side.
Meanwhile I did it. Here is the result if somebody is interested:
/**
* Converts Win32 FILETIME structure (represented as 2 longs) to the Palm
time (Seconds since 1.1.1904)
*/
static unsigned long FILETIMEtoSeconds( unsigned long hiTime, unsigned long
loTime )
{
/*
1904 - 1601 = 303.
# of leap years: 303/4 -3 = 72. (Every 4 yrs except 1700, 1800, and
1900.)
# of non-leap years: 231
(72*366 + 231*365)*86400 = (26352 + 84315)*86400 = 110667*86400 =
9561628800
*/
static const long long SECS_BETWEEN_1601_AND_1904 = 9561628800 ;
// Convert units [100 nsecs] to [secs]
long long secs = (((long long)hiTime << 32) + loTime) / 10000000 ;
return secs - SECS_BETWEEN_1601_AND_1904 ;
}
----- Original Message ----- > >
> >Does anybody know how to convert Win32 FILETIME structure (number of
> >100-nanosecond intervals since January 1, 1601 written as 2 unsigned
longs)
> >to the Palm time format? (Presumably without 64-bit arithmetic.)
>
> Why not use 64-bit arithmetic? It is supported by both C/C++ toolsets,
AFAIK.
>
> If you're doing this on the desktop, there are Win32 API calls that can
> convert a FILETIME to a seconds count. I'd start by getting the FILETIME
> of the Palm OS baseline (January 1, 1904 at 0:00), doing a subtract, and
> then scaling by dividing the result by 10,000,000, the number of
> 100-nanoseconds in a second.
>
> Also in Win32, you could use FileTimeToSystemTime, and then take the
> SYSTEMTIME structure members and push them into a standard C library
> function to convert to a second count.
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/