]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
Use standard interfaces to get timezone offsets.
authorM. Warner Losh <wlosh@netflix.com>
Thu, 4 Oct 2018 21:37:17 +0000 (15:37 -0600)
committerM. Warner Losh <wlosh@netflix.com>
Thu, 4 Oct 2018 21:37:17 +0000 (15:37 -0600)
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.

wdc-utils.c
wdc-utils.h

index 351023aee5a621c1a0b4eaa7da6f84b5958c923f..14225d40e3e5518f1219738613bdab278a8f9347 100644 (file)
@@ -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;
 }
index 8d875e2e88eecdc20af72dd9f1e770ef5c004aa6..0234227884b1efbba2a80be7218be4cd6ddc43f7 100644 (file)
@@ -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;
-