[Bug 1819035] [NEW] strptime loses one hour if TZ set to Dublin

Mark Burkley mark at burkley.net
Thu Mar 7 16:58:34 UTC 2019


Public bug reported:

glibc version 2.28-0ubuntu1


If timezone is set to Dublin, strptime returns one hour less than it should.  Timezone set to London works fine, but Dublin and London are in the same time zone.  DST is not active.

mark at sotera:~/build-glibc$ TZ='Europe/Dublin'; ./test 
t(orig)=1551972563
s=2019-03-07T15:29:23GMT+0000

calling strptime
t(new)=1551968963
s=2019-03-07T14:29:23

mark at sotera:~/build-glibc$ TZ='Europe/London'; ./test 
t(orig)=1551972570
s=2019-03-07T15:29:30GMT+0000
calling strptime
t(new)=1551972570
s=2019-03-07T15:29:30

where test.c is the following:

#define _XOPEN_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <time.h>

int main (void)
{
    struct tm tms;
    time_t t;
    char s[100];
    int sec;

    t = time (NULL);
    printf ("t(orig)=%d\n", (int) t);

    gmtime_r (&t, &tms);
    strftime (s, 90, "%Y-%m-%dT%H:%M:%S%Z%z", &tms);
    printf ("s=%s\n", s);

    memset (&tms, 0, sizeof (struct tm));
    printf("calling strptime\n");
    char *unproc = strptime (s, "%Y-%m-%dT%H:%M:%S%Z", &tms);
    t = mktime(&tms);
    printf ("t(new)=%d\n", (int) t);

    gmtime_r (&t, &tms);
    strftime (s, 90, "%Y-%m-%dT%H:%M:%S", &tms);
    printf ("s=%s\n", s);

    return 0;
}

** Affects: glibc (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: glibc strptime

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to glibc in Ubuntu.
https://bugs.launchpad.net/bugs/1819035

Title:
  strptime loses one hour if TZ set to Dublin

Status in glibc package in Ubuntu:
  New

Bug description:
  glibc version 2.28-0ubuntu1

  
  If timezone is set to Dublin, strptime returns one hour less than it should.  Timezone set to London works fine, but Dublin and London are in the same time zone.  DST is not active.

  mark at sotera:~/build-glibc$ TZ='Europe/Dublin'; ./test 
  t(orig)=1551972563
  s=2019-03-07T15:29:23GMT+0000

  calling strptime
  t(new)=1551968963
  s=2019-03-07T14:29:23

  mark at sotera:~/build-glibc$ TZ='Europe/London'; ./test 
  t(orig)=1551972570
  s=2019-03-07T15:29:30GMT+0000
  calling strptime
  t(new)=1551972570
  s=2019-03-07T15:29:30

  where test.c is the following:

  #define _XOPEN_SOURCE
  #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
  #include <strings.h>
  #include <time.h>

  int main (void)
  {
      struct tm tms;
      time_t t;
      char s[100];
      int sec;

      t = time (NULL);
      printf ("t(orig)=%d\n", (int) t);

      gmtime_r (&t, &tms);
      strftime (s, 90, "%Y-%m-%dT%H:%M:%S%Z%z", &tms);
      printf ("s=%s\n", s);

      memset (&tms, 0, sizeof (struct tm));
      printf("calling strptime\n");
      char *unproc = strptime (s, "%Y-%m-%dT%H:%M:%S%Z", &tms);
      t = mktime(&tms);
      printf ("t(new)=%d\n", (int) t);

      gmtime_r (&t, &tms);
      strftime (s, 90, "%Y-%m-%dT%H:%M:%S", &tms);
      printf ("s=%s\n", s);

      return 0;
  }

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/1819035/+subscriptions



More information about the foundations-bugs mailing list