Hi,
Thanks for your reply. This is the code which I am
using. Still I am getting wrong dates after sync on
palm. I am able to sync data from palm to pc. For pc
to palm sync I am reading data from text file, and for
every record the date is diff.. I am reading date from
the text file and storing into array say.
char PcDate[] = "10/12/2001"; ( dd/mm/yyyy format)
then I am taking out day,month and year .
unsigned char
dateDay[4],dateMonth[4],dateYear[5],dateItem[5];
int slashCount;
for ( i = 0 ,slashCount = 0 , j = 0 ; PcDate[i] !=
'\0' ; i++)
{
if (PcDate[i] != '/' )
dateItem[j++] = field[i];
else
{
slashCount++;
dateItem[j++] = '\0';
if ( slashCount == 1 )
{
strcpy((char *)dateDay ,(char *) dateItem);
j = 0;
month = atoi((char *)dateDay);
}
else
{
if ( slashCount == 2 )
{
strcpy((char *)dateMonth ,(char *) dateItem );
j = 0;
day = atoi((char *)dateMonth);
}
}
}
}
dateItem[j++] = '\0';
strcpy((char *)dateYear ,(char *) dateItem) ;
year = atoi((char *)dateYear);
then I have stucture which I am passing to palm
thorugh sync.
stuct XDB
{
DateType date; // DateTYpe
char *amt;
etc....
};
XDB XData;
XData.date.year = year - 1904;
XData.date.month = month;
XData.date.year = day;
In debug if I chck the value of date of XDB then I am
getting corect values. Say if date is "12/10/2001".
then I get XData.date.year = 97 ( 2001-1904 = 97)
XData.date.month = 12 and XData.date.day = 10.
IF I use the SyncHHToHostWord then I get 0 values of
day,month. It is possible that instead of takeing
DateType member in XDB , take WORD date and using
simple variable of DateType assigin whole datetype to
WORD date member of XDB by SyncHHHostWord.
But that also doesnt work. So tell me where I am
worng. I dont know what goes wrong after sync. It is
possible that problem is with palm application, but I
am able to read the date from palm to pc. And Palm
application is working nicely. So if u have any idea
then pls tell me.
Regards,
Vini
--- Chris Tutty <[EMAIL PROTECTED]>
wrote:
> "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/
__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/