From: M. Warner Losh Date: Thu, 4 Oct 2018 21:37:17 +0000 (-0600) Subject: Use standard interfaces to get timezone offsets. X-Git-Tag: v1.7~46^2~1 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=559c0f04ba6461997bdfa1cc8eae948dd01693ed;p=users%2Fsagi%2Fnvme-cli.git Use standard interfaces to get timezone offsets. Use the tm_gmtoff returned from localtime() rather than the global timezone. The formal is more portable, while the latter is specific to glibc. There's no good reason to use the glibc specific interface. --- diff --git a/wdc-utils.c b/wdc-utils.c index 351023ae..14225d40 100644 --- a/wdc-utils.c +++ b/wdc-utils.c @@ -65,22 +65,20 @@ int wdc_UtilsGetTime(PUtilsTimeInfo timeInfo) time_t currTime; struct tm currTimeInfo; + tzset(); time(&currTime); localtime_r(&currTime, &currTimeInfo); timeInfo->year = currTimeInfo.tm_year + 1900; timeInfo->month = currTimeInfo.tm_mon + 1; timeInfo->dayOfWeek = currTimeInfo.tm_wday; - timeInfo->dayOfMonth = currTimeInfo.tm_mday; + timeInfo->dayOfMonth = currTimeInfo.tm_mday; timeInfo->hour = currTimeInfo.tm_hour; timeInfo->minute = currTimeInfo.tm_min; timeInfo->second = currTimeInfo.tm_sec; timeInfo->msecs = 0; timeInfo->isDST = currTimeInfo.tm_isdst; - - tzset(); - - timeInfo->zone = -1 * (timezone / SECONDS_IN_MIN); + timeInfo->zone = -currTimeInfo.tm_gmtoff / 60; return WDC_STATUS_SUCCESS; } diff --git a/wdc-utils.h b/wdc-utils.h index 8d875e2e..02342278 100644 --- a/wdc-utils.h +++ b/wdc-utils.h @@ -75,7 +75,3 @@ int wdc_UtilsStrCompare(char *pcSrc, char *pcDst); int wdc_UtilsCreateDir(char *path); int wdc_WriteToFile(char *fileName, char *buffer, unsigned int bufferLen); -extern char *tzname[2]; -extern long timezone; -extern int daylight; -