Hello all,
Always promised to join and finally did. Great forums.

Any way, I'm developing a few conduits for palm and ran into
a problem with parsing the dates out of the palm db.
I received some code from a "C" friend who does not know
C#. I tried translating however, I'm stuck with some of the
old c style formats.

Help.

C code.

<code>
void ConvertTheDate( char * inpbuffer, char * thedate )
{
unsigned long newdate;
unsigned long adjust = 0x7c25b080;
struct tm *pcTime;
char work[26];

newdate = 0;
newdate = (inpbuffer[0] & 0x000000ff) << 24;
newdate |= (inpbuffer[1] & 0x000000ff) << 16;
newdate |= (inpbuffer[2] & 0x000000ff) << 8;
newdate |= inpbuffer[3] & 0x00000ff;
//Adjust the date relative to 1/1/1904 to 1/1/1970
newdate -= adjust;
pcTime = gmtime( &newdate );
if (pcTime == NULL)
{
time( &newdate );
pcTime = gmtime( &newdate);
}
sprintf( work, "%s", asctime( pcTime ) );
//Remove the day of the week for the SQL convert to datetime
strncpy( thedate, &work[4], strlen(work) - 5 );
}

My limited translation

public static string convert_palm_date(string thedate)
{

long newdate;
long adjust = 0x7c25b080;
DateTime pcTime;
char[] work = new char[26];
newdate = 0;
int i=0;
char[] return_date = new char[20];
try
{
foreach(char dt in thedate)
{
return_date[i] = dt;
i++;
}

newdate = (return_date[0] & 0x000000ff) << 24;
newdate |= (return_date[1] & 0x000000ff) << 16;
newdate |= (return_date[2] & 0x000000ff) << 8;
newdate |= return_date[3] & 0x00000ff;
//Adjust the date relative to 1/1/1904 to 1/1/1970
newdate -= adjust;
pcTime = DateTime.Parse(
newdate.ToString)).ToUniversalTime();
return pcTime.ToString();

}
catch(Exception exc){return exc.Message;}

return thedate;


}
</code>