Try this (the manual addition...):

[snip]

SelectDay(selectDayByDay, &shMonth, &shDay, &shYear, cTitle);

DateType *dt6DaysPrior = new DateType;
dt6DaysPrior->day = shDay;
dt6DaysPrior->month = shMonth;
dt6DaysPrior->year = shYear-1904;

DateToAscii (dt6DaysPrior->month, dt6DaysPrior->day, 1904+dt6DaysPrior->year,
dfMDYLongWithComma, c6DaysPriorDate);
FldSetTextPtr(txtStartDay, c6DaysPriorDate);
FldEraseField(txtStartDay);
FldDrawField(txtStartDay);


[snap]

I believe SelectDate returns the comlete year (i.e. 2004), so you need to subtract 1904 because DateString takes the year the Macintosh way: Years since 1904. Therefor you have to add them again on displaying...

Tell me if this work for you...

/morten



Ornstein, Adam wrote:
Keeps coming up as 100...   I also tried setting shYear to 2004, 100, etc.
But it never comes up right...

Here is some code, please help!

SelectDay(selectDayByDay, &shMonth, &shDay, &shYear, cTitle);

DateType *dt6DaysPrior = new DateType;
dt6DaysPrior->day = shDay;
dt6DaysPrior->month = shMonth;
dt6DaysPrior->year = shYear;

DateToAscii (dt6DaysPrior->month, dt6DaysPrior->day, dt6DaysPrior->year,
dfMDYLongWithComma, c6DaysPriorDate);
FldSetTextPtr(txtStartDay, c6DaysPriorDate);
FldEraseField(txtStartDay);
FldDrawField(txtStartDay);

-----Original Message-----
From: Morten Schmidt [mailto:[EMAIL PROTECTED] Sent: Thursday, April 15, 2004 11:14 AM
To: Palm Developer Forum
Subject: Re: DateType problem, convert to ascii...


Since it is always 1904 years apart, I manually add or subtract the value 1904 to or from the value stored i DateType. Works for me...

/morten

PS I'm quite new at programming for the PalmOS

Ornstein, Adam wrote:

1.
Im using a datetype, and even though the year variable is set to 2004,
it always shows up as year 84.  I know how that the year field is
supposed to be an unsigned short type, and that the value is supposed
to be The number of years since 1904.

however assigning year the value of 100 still does not solve the
issue. The year will come up as 100.


Im also using the DateToAscii (); function provided to convert the date

to


a character array...

2.
Im trying to set the text value to the text of a selection strigger

object,


that is why I am converting it to ascii.


any advice? Thanks!!





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

Reply via email to