R
red floyd
Is there a portable way to convert between a struct tm and a time_t, for UTC?
I know that time_t is seconds since the epoch (1970-01-01T00:00:00Z).
Now, you can convert a time_t to a struct tm for either local (localtime()) or UTC (gmtime()).
But the reverse operation (mktime()) only converts a local time, as far as I can tell. What I'm
looking for is a portable way to convert a struct tm holding a UTC value into a time_t.
I'm currently using an OS specific kludge which involves setting the TZ environment variable, and
I know this is highly non-portable. Anybody got a better idea?
Thanks
I know that time_t is seconds since the epoch (1970-01-01T00:00:00Z).
Now, you can convert a time_t to a struct tm for either local (localtime()) or UTC (gmtime()).
But the reverse operation (mktime()) only converts a local time, as far as I can tell. What I'm
looking for is a portable way to convert a struct tm holding a UTC value into a time_t.
I'm currently using an OS specific kludge which involves setting the TZ environment variable, and
I know this is highly non-portable. Anybody got a better idea?
Thanks