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

c# - SelectList with Dictionary, add values to the Dictionary after it's assigned to SelectList -

how can i manage url using .htaccess in php? -

ios - I get the error Property '...' not found on object of type '...' -