Getting GMT time into a CTime
Posted on 2001-06-29
When our server passes time/date values to clients, it does so in a formatted string representing the time in GMT (UTC). It's easy to get UTC from a CTime object with FormatGmt(), but there does not seem to be a way to put UTC back into another CTime object after we parse that string. Any time that I give to CTime seems to be interpreted as local time.
A clumbsy workaround is to store the original values of _timezone and _daylight (global variables in C runtime), set them to 0, construct my CTime object, then restore the variables. This works, but is ugly and obviously not threadsafe.
Can anyone offer a better alternative?
In short, I'm looking for a function like:
CTime GetCTimeFromGmt(int year, int month, int day, int hour, int minute, int second)
where the passed parameters are relative to GMT. The function must be thread safe.