"Vini P" <[EMAIL PROTECTED]> wrote
> WORD day = 12;
> WORD month = 12;
> WORD year = 2001;
>
> DateType date;
> date.dat = SyncHHToHostWord(day);
> date.month = SyncHHToHostWord (month);
> date.year = SyncHHToHostWord (year);
>
Well, I don't do a lot of hotsync stuff so I'm a bit confused as
to why you're doing things this way. The structure you've
defined packs the three fields into one Word using the bit
widths defined. That means that you should use
SyncHHToHostWord on the whole structure, possibly requiring
a cast to Word. Since this provides the desktop representation
of the Word I don't understand why you're creating the value
since this seems like a function for use with data created on the
Palm, but I'll go along.
I'd have thought that the code should be:
WORD day = 12;
WORD month = 12;
WORD year = 2001;
DateType date;
Word Result = 0;
date.day = day;
date.month = month;
date.year = year;
Result = SyncHHToHostWord(date);
of course, unless you do something else with day, month and year
wouldn't it be faster to do:
DateType date = {12,12,2001};
Result = SyncHHToHostWord(date);
As I said above, you might need to cast to WORD
Result = SyncHHToHostWord((WORD)date);
But as I said above, if this code is running on the desktop then the
date structure you create is already in the desktop format so this
code seems to be the wrong way around.
Result = SyncHHToHostWord((WORD)date);
I'd have thought that you'd use it like this:
date = (DateType) SyncHHToHostWord(SomeWordValueFromHandHeld);
printf("Day, Month, Year = %d, %d, %d", date.day, date.month, date.year);
My guess is that the year would need 1904 added to it to be correct.
As I said, I've never used these routines (my projects all call for direct
reading and writing of pdbs rather than syncing) so this is all just
guess-work.
Chris Tutty
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/