C++ mktime and DST -


i processing stored dates , times. store them in file in gmt in string format (i.e. ddmmyyyyhhmmss). when client queries, convert string struct tm, convert seconds using mktime. check invalid datetime. again convert seconds string format. these processing fine, no issues @ all.

but have 1 weird issue: stored date , time in gmt locale gmt. because of day light saving, locale time changed gmt+1. now, if query stored date , time 1 hour less because mktime function uses locale, i.e. gmt+1, convert struct tm seconds (tm_isdst set -1 mktime detects daylight savings etc. automatically).

any ideas how solve issue?

use _mkgmtime/timegm complement mktime.

time_t mkgmtime(struct tm* tm) { #if defined(_win32)    return _mkgmtime(tm); #elif defined(linux)    return timegm(tm); #endif } 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -