E
Ekong, Samuel Akpan
Hi,
I am parsing a binary file and intend to read a date(not time) field encoded
thus:
0xA1290B(little-endian).
Now I know the date to be 12/04/2003 but just cannot get any of the known
datetime functions to return this value either as a tm structure or as a
string value. It's more accurate to say that my attempts return a date in
the year 1970. I have been able to read the time accurately but I just want
to be able to parse correctly the date. Any assistance will be appreciated.
Skeleton sample code shown below:
Thanks.
Samuel.
//necessary headers assumed to have been included
int main(int argc, char* argv[])
{
if( _putenv( "TZ=PST-PDT" ) == -1 )
{
printf( "Unable to set TZ\n" );
exit( 1 );
}
else
{
_tzset();
printf( "_daylight = %d\n", _daylight );
printf( "_timezone = %ld\n", _timezone );
printf( "_tzname[0] = %s\n", _tzname[0] );
printf( "_tzname[1] = %s\n", _tzname[1] );
}
time_t _theTempTime= 38965;
time_t _theTempDate= 731553;
time_t _theTempDateTime = time(&_theTempDate);
char* theStringTime = ctime(&_theTempTime);
struct tm* _theTM = gmtime(&_theTempDateTime);
struct tm* _theTML = localtime(&_theTempDate);
return 0;
I am parsing a binary file and intend to read a date(not time) field encoded
thus:
0xA1290B(little-endian).
Now I know the date to be 12/04/2003 but just cannot get any of the known
datetime functions to return this value either as a tm structure or as a
string value. It's more accurate to say that my attempts return a date in
the year 1970. I have been able to read the time accurately but I just want
to be able to parse correctly the date. Any assistance will be appreciated.
Skeleton sample code shown below:
Thanks.
Samuel.
//necessary headers assumed to have been included
int main(int argc, char* argv[])
{
if( _putenv( "TZ=PST-PDT" ) == -1 )
{
printf( "Unable to set TZ\n" );
exit( 1 );
}
else
{
_tzset();
printf( "_daylight = %d\n", _daylight );
printf( "_timezone = %ld\n", _timezone );
printf( "_tzname[0] = %s\n", _tzname[0] );
printf( "_tzname[1] = %s\n", _tzname[1] );
}
time_t _theTempTime= 38965;
time_t _theTempDate= 731553;
time_t _theTempDateTime = time(&_theTempDate);
char* theStringTime = ctime(&_theTempTime);
struct tm* _theTM = gmtime(&_theTempDateTime);
struct tm* _theTML = localtime(&_theTempDate);
return 0;