local-tz-offet return 3600 on Jul 13 in EST

Create issue
Issue #137 resolved
Takashi Kato repo owner created an issue

On Linux, local-tz-offset returns 3600 on Jul 13 in EST. In this period, it should return 7200.

NOTE: if tm_isdst is not set (or 0) then it return 7200 however this behaviour is totally implementation dependent.

Comments (2)

  1. Takashi Kato reporter

    Checking snipet:

    #!c
    #include <stdio.h>
    #include <time.h>
    #include <stdint.h>
    int main()
    {
      struct tm localTime;
      struct tm utcTime, *gmt;
      time_t current = time(NULL);
      time_t l;
    #ifdef _WIN32
      localtime_s(&localTime, &current);
      l = mktime(&localTime);
      gmtime_s(&utcTime, &l);
    #else
      localtime_r(&current, &localTime);
      localTime.tm_mon = 12;
      l = mktime(&localTime);
      gmtime_r(&l, &utcTime);
    #endif
      printf("Local time is : %s", asctime(&localTime));
      printf("UTC time is : %s", asctime(&utcTime));
      printf("tm_isdst: utc:%d, local:%d\n", utcTime.tm_isdst, localTime.tm_isdst);
      localTime.tm_isdst = 0;
      printf("offset: %ld\n", (int64_t)mktime(&localTime) - mktime(&utcTime));
      printf("offset: %ld\n", localTime.tm_gmtoff);
      return 0;
    }
    
  2. Log in to comment