rtnMichael
Programmer
can someone help me out here, I am having trouble seeing what's wrong with this code. the first portion works, but the second doesn't like how I did the tm structure fill (I assume).
*************************first portion********************
struct tm file_tm = {30,40,3,15,2,73};
struct tm *file_time;
time_t TheTime;
if( (TheTime = mktime(&file_tm) ) != -1 )
printf("<%s>\n" , asctime(&file_tm) );
file_time = localtime(&TheTime);
printf("%s\n", asctime(file_time));
************************second portion*******************
struct tm *file_time;
struct tm file_tm;
time_t TheTime;
if((sscanf(target->hdr.time,"%2d%2d%1d", &file_tm.tm_hour, &file_tm.tm_min, &tenth) != 3) ||
(sscanf(target->hdr.date,"%2d%2d%2d", &file_tm.tm_mon, &file_tm.tm_mday, &file_tm.tm_year) != 3))
return("Unknown"
file_tm.tm_sec = tenth * 6;
file_tm.tm_year += (file_tm.tm_year < 70 ) ? 2000 : 1900;
///////Here's where it gives me the problem, it returns -1
if((TheTime = mktime(&file_tm)) != -1 )
printf("<%s>\n" , asctime(&file_tm) );
file_time = localtime(&TheTime);
printf("%s\n", asctime(file_time));
Any help would be greatly appreciated.
Thanks
Michael
*************************first portion********************
struct tm file_tm = {30,40,3,15,2,73};
struct tm *file_time;
time_t TheTime;
if( (TheTime = mktime(&file_tm) ) != -1 )
printf("<%s>\n" , asctime(&file_tm) );
file_time = localtime(&TheTime);
printf("%s\n", asctime(file_time));
************************second portion*******************
struct tm *file_time;
struct tm file_tm;
time_t TheTime;
if((sscanf(target->hdr.time,"%2d%2d%1d", &file_tm.tm_hour, &file_tm.tm_min, &tenth) != 3) ||
(sscanf(target->hdr.date,"%2d%2d%2d", &file_tm.tm_mon, &file_tm.tm_mday, &file_tm.tm_year) != 3))
return("Unknown"
file_tm.tm_sec = tenth * 6;
file_tm.tm_year += (file_tm.tm_year < 70 ) ? 2000 : 1900;
///////Here's where it gives me the problem, it returns -1
if((TheTime = mktime(&file_tm)) != -1 )
printf("<%s>\n" , asctime(&file_tm) );
file_time = localtime(&TheTime);
printf("%s\n", asctime(file_time));
Any help would be greatly appreciated.
Thanks
Michael