unstable mktime result

Bug #1437534 reported by Filipe Dias
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
glibc (Ubuntu)
New
Undecided
Unassigned

Bug Description

Hi all,

Mktime has different results when using dates that coincide with times that "didn't" exist due to a change of the reference for the specific timezone. In the examples I've run, when it's first called, it returns a past (IMHO invalid) value. After it's called for another date, calling it again for the first date, returns the expected result.

I found this happens on 1912-01-01 for Europe/Lisbon timezone and 1910-10-01 for Europe/Istanbul and it may be happening on other cases. I also found a similar case where it doesn't happen, 1940-05-15 for Europe/Amsterdam.

The tests I made are available here: https://gist.github.com/fmfdias/5c7c36726ff3cce12ead

Running them:
gcc test_europe_lisbon_glibc.c -o test_europe_lisbon_glibc
TZ='Europe/Lisbon' ./test_europe_lisbon_glibc

gcc test_europe_istanbul_glibc.c -o test_europe_istanbul_glibc
TZ='Europe/Istanbul' ./test_europe_istanbul_glibc

gcc test_europe_amsterdam_glibc.c -o test_europe_amsterdam_glibc
TZ='Europe/Amsterdam' ./test_europe_amsterdam_glibc

Although I run these tests on Ubuntu 14.10, I saw this also happening on a Ubuntu 12.04 machine.

lsb_release -rd
Description: Ubuntu 14.10
Release: 14.10

sudo apt-cache policy libc6
libc6:
  Installed: 2.19-10ubuntu2.3
  Candidate: 2.19-10ubuntu2.3
  Version table:
 *** 2.19-10ubuntu2.3 0
        500 http://archive.ubuntu.com/ubuntu/ utopic-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu/ utopic-security/main amd64 Packages
        100 /var/lib/dpkg/status
     2.19-10ubuntu2 0
        500 http://archive.ubuntu.com/ubuntu/ utopic/main amd64 Packages

Thank you!

Revision history for this message
Andor Rozsnyai (arozsny) wrote :

I had the I think the same problem with mktime().
(Ubuntu EGLIBC 2.19-0ubuntu6.8) 2.19

With input data:
struct tm testtime = {0};
    testtime.tm_year=10;
    testtime.tm_mon=0;
    testtime.tm_mday=1;
    testtime.tm_hour=0;
    testtime.tm_min=0;
    testtime.tm_sec=0;

mktime(t) int -1893459600 for "Europe/Budapest"
mktime(t) int -1893456000 for "Europe/London"
mktime(t) int -1893462264 ??? for "Europe/Bucharest"

for
struct tm testtime = {0};
    testtime.tm_year=50;
    testtime.tm_mon=0;
    testtime.tm_mday=1;
    testtime.tm_hour=0;
    testtime.tm_min=0;
    testtime.tm_sec=0;

mktime(t) int -631155600 for "Europe/Budapest"
mktime(t) int -631152000 for "Europe/London"
mktime(t) int -631159200 for "Europe/Bucharest"
mktime(t) int -631134000 for "America/Nipigon"

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.