Skip to content
Snippets Groups Projects
Commit 702a8ff9 authored by rswindell's avatar rswindell
Browse files

Using portable method of determining if DST is in effect (localtime).

parent d62a17df
No related branches found
No related tags found
No related merge requests found
......@@ -52,9 +52,12 @@ BOOL DLLCALL load_cfg(scfg_t* cfg, char* text[], BOOL prep, char* error)
int i;
long line=0L;
FILE *instream;
#ifdef _WIN32
#if 0 //def _WIN32
TIME_ZONE_INFORMATION tz;
DWORD tzRet;
#else
time_t now;
struct tm tm;
#endif
if(cfg->size!=sizeof(scfg_t)) {
......@@ -129,12 +132,20 @@ BOOL DLLCALL load_cfg(scfg_t* cfg, char* text[], BOOL prep, char* error)
/* Auto-toggle daylight savings time in US time-zones */
if(cfg->sys_misc&SM_AUTO_DST
&& !OTHER_ZONE(cfg->sys_timezone) && cfg->sys_timezone&US_ZONE) {
#ifdef _WIN32
#if 0 //def _WIN32
tzRet=GetTimeZoneInformation(&tz);
if(tzRet==TIME_ZONE_ID_STANDARD)
cfg->sys_timezone&=~DAYLIGHT;
else if(tzRet==TIME_ZONE_ID_DAYLIGHT)
cfg->sys_timezone|=DAYLIGHT;
#else
now=time(NULL);
if(localtime_r(&now,&tm)!=NULL) {
if(tm.tm_isdst>0)
cfg->sys_timezone|=DAYLIGHT;
else if(tm.tm_isdst==0)
cfg->sys_timezone&=~DAYLIGHT;
}
#endif
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment