Similar to:
Convert historical time to GMT
This time my scenario is: I need to convert some string times in the format "2011061411322100" into GMT. The problem is that the times are coming from another PC and is a historical time. So I am not getting the times in real time so I cannot simply get the GMT from the local time on the box that my code is running.
The times represent Start and End times. If my code is running during a time change, the time change will bre applied on the remote box where I am getting the times. So if the change happens betwwen the start and end time, then the end time will be offset.
I assume I must first convert to tm:
// add to tm struct
tm tmTime;
tmTime.tm_hour = hour;
tmTime.tm_min = min;
tmTime.tm_sec = sec;
tmTime.tm_mday = day;
tmTime.tm_mon = (month-1);
tmTime.tm_year = (year - 1900);
Then convert to time_t
time_t tmInTime_t = mktime( &tmTime );
Then use gmtime:
struct tm *gmt = gmtime( &tmInTime_t );
This will still cause large delta if time change happens between start and end. How do I fix? Do I need to set .tm_isdst? How do I know what to set to?