This code (for the sample below) doesn't work!
ULong addSeconds = (4 * 365.25 * 24 * 60 * 60); // add
It has two problems:
a) 365.25 (there's better ways for leap year adjustment!)
b) you have to cast the constants to long, otherwise the compiler
uses int for intermediate values and you get overflow problems
ex: 24 * 60 * 60
should be 24L * 60L * 60L
Roger Stringer
Marietta Systems, Inc
Creators of the Marietta PDE (tm) RAD software for the Palm OS (r)
>----------------------------------------------------------------------
>Subject: RE: DateTimeType vs. DateType
>From: "Aaron Hansen" <[EMAIL PROTECTED]>
>Date: Wed, 21 Jun 2000 14:01:05 -0700
>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;
--
For information on using the ACCESS Developer Forums, or to unsubscribe, please
see http://www.access-company.com/developers/forums/