Hello Mark,

Your problem is that the value for years stored in DateType is the years
since 1904.  In order to get the current year you have to add 1904 to it (or
firstYear).  For the year 2000, you would see 96 which looks like it's 4
years off but isn't if you apply the above adjustment.  In your code you
added 4 to 96 which of course made it 100, or 100 years since 1904.

        Hope it helps,

        Aaron Hansen


> -----Original Message-----
> From: Mark W. Alme [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 21, 2000 2:34 PM
> To: Palm Developer Forum
> Subject: DateTimeType vs. DateType
> 
> 
> Hello:
> 
>       I was having trouble using DateTypes:
> <code>
>       ULong seconds = TimGetSeconds();
> 
>       DateType date;
>       DateSecondsToDate(TimGetSeconds(), &date);
>       // date now 4 years prior to current date
> 
>       ULong addSeconds = (4 * 365.25 * 24 * 60 * 60); // add 
> four years
>       seconds += addSeconds;
>       DateSecondsToDate(seconds, &date);
>       // date now current day of the year 100 (when current 
> date in 2000)
>       // is this some sort of y2k problem?
> 
>       // using DateTimeType seems to fix the problem
>       DateTimeType timer;
> 
>       TimSecondsToDateTime(TimGetSeconds(), &timer);
>        // timer now has correct current date.
> 
> </code>
> 
>       Does anyone know if there is a know advantage for using 
> DateTimeTypes versus using DateTypes?  I saw a post on the archives 
> where a developer wondered if DateTypes even existed in the api. 
> Advice welcome.
> 
> Mark
> 
> 
> -- 
> 
> Mark W. Alme
> Analyst
> Alme & Associates
> 
> -- 
> For information on using the Palm Developer Forums, or to 
> unsubscribe, please see http://www.palmos.com/dev/tech/support/forums/
> 
> 


-- 
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