if you just need to track the date and not the time (hours, minutes, seconds) then:

DateType date;
UInt32 days;
date.year=2000 - 1904; /* The number of years since 1904 */
date.month=2;
date.day=23;

days=DateToDays(date);
days+=120;

DateDaysToDate(days, &date);

remember the field year is the number of years since 1904 and not the year itself.

If you need the time then you have to use TimDateTimeToSeconds and TimSecondsToDateTime and DateTimeType, and add seconds instead of days (and the field "year" stores the year, not the number of years since 1904 as DateType does).

Hope this helps
Miguel

Udi Kobi wrote:

Hi,
I am trying to take a date and add X days to it.
Which is the way to do it?

My code:
   DateTimeType myDate;
   myDate.year = 2000;
   myDate.month = 2;
   myDate.day = 23;
   myDate += 120; // rejected by compiler Regards,
-Udi



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

Reply via email to