This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author belopolsky
Recipients akira, belopolsky, lemburg, pitrou
Date 2016-09-13.17:19:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1473787195.46.0.90007700635.issue22798@psf.upfronthosting.co.za>
In-reply-to
Content
I ran the attached test-mktime.c program on Linux and MacOS X with the following results (TZ=America/New_York):

$ cat test-mktime.c
#include <time.h>
#include <stdio.h>
static void
print_globals(struct tm *tm)
{
  printf("%04d-%02d: %s/%s (%s) %d %ld (%ld)\n",
       	 1900 + tm->tm_year, 1 + tm->tm_mon,
       	 tzname[0], tzname[1], tm->tm_zone?tm->tm_zone:"NULL",
       	 daylight, timezone, -tm->tm_gmtoff);
}

int main() {
  struct tm tm = {0, 0, 0, 1, 0, -100};
  print_globals(&tm);
  tzset();
  print_globals(&tm);
  mktime(&tm);
  print_globals(&tm);
  tm.tm_year = 43;
  mktime(&tm);
  print_globals(&tm);
  tm.tm_year = 45;
  tm.tm_mon = 8;
  mktime(&tm);
  print_globals(&tm);
}

Linux:

$ gcc test-mktime.c && ./a.out
1800-01: GMT/GMT (NULL) 0 0 (0)
1800-01: EST/EDT (NULL) 1 18000 (0)
1800-01: LMT/EDT (LMT) 1 18000 (17762)
1943-01: EST/EWT (EWT) 1 18000 (14400)
1945-09: EST/EPT (EPT) 1 18000 (14400)


MacOS X:

$ clang test-mktime.c && ./a.out
1800-01: WILDABBR/WILDABBR (NULL) 0 0 (0)
1800-01: EST/EDT (NULL) 1 18000 (0)
1800-01: EST/EDT (NULL) 1 18000 (0)
1943-01: EST/EWT (EWT) 1 18000 (14400)
1945-09: EST/EPT (EPT) 1 18000 (14400)

Indeed, mktime changes tzname as a side effect, but the result is system dependent (see LMT/EDT vs. EST/EDT in the third line).

Furthermore, the values of daylight and timezone variables do not get updated, resulting in an inconsistent state.  For this reason, I don't think Python should expose the new values of tzname.  People who really need access to those can use ctypes.
History
Date User Action Args
2016-09-13 17:19:55belopolskysetrecipients: + belopolsky, lemburg, pitrou, akira
2016-09-13 17:19:55belopolskysetmessageid: <1473787195.46.0.90007700635.issue22798@psf.upfronthosting.co.za>
2016-09-13 17:19:55belopolskylinkissue22798 messages
2016-09-13 17:19:55belopolskycreate