strptime loses one hour if TZ set to Dublin

Bug #1819035 reported by Mark Burkley
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
glibc (Ubuntu)
New
Undecided
Unassigned

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@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@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;
}

Tags: glibc strptime
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.