[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#523280: localtime doesn't count leap seconds near 2038



Package: libc6
Version: 2.7-18

I found that date command doesn't work well with leap
seconds after 2037-11-01 with right/EST5EDT timezone.

% TZ=right/EST5EDT date -d @2140668023
Sun Nov  1 01:59:59 EDT 2037
% TZ=right/EST5EDT date -d @2140668024
Sun Nov  1 01:00:24 EST 2037

The second after 01:59:59 EDT should be 01:00:00 EST, not
01:00:24 EST.

It seems a problem of localtime().

% cat localtime.c 
#include <stdlib.h>
#include <stdio.h>
#include <time.h>

int main(int argc, char *argv[])
{
  time_t t;
  struct tm *tmp;

  t = atol(argv[1]);

  tmp = localtime(&t);
  if (tmp == NULL) { fprintf(stderr, "localtime error\n"); exit(1); }

  printf("%d-%02d-%02d %02d:%02d:%02d %s %s (%ld) %ld\n",
    tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
    tmp->tm_hour, tmp->tm_min, tmp->tm_sec,
    tmp->tm_isdst > 0 ? "dst" : tmp->tm_isdst == 0 ? "std" : "unknown",
    tmp->tm_zone, tmp->tm_gmtoff,
    t);

  return 0;
}
% gcc -Wall localtime.c
% TZ=right/EST5EDT ./a.out 2140668023
2037-11-01 01:59:59 dst EDT (-14400) 2140668023
% TZ=right/EST5EDT ./a.out 2140668024
2037-11-01 01:00:24 std EST (-18000) 2140668024

% dpkg -l|grep libc6
ii  libc6                                2.7-18                      GNU C Library: Shared libraries
ii  libc6-dbg                            2.7-18                      GNU C Library: Libraries with debugging symbols
ii  libc6-dev                            2.7-18                      GNU C Library: Development Libraries and Header Files
ii  libc6-i686                           2.7-18                      GNU C Library: Shared libraries [i686 optimized]
% dpkg -l|grep tz   
ii  tzdata                               2008h-2                     time zone and daylight-saving time data
% uname -a
Linux nute 2.6.26-1-486 #1 Fri Mar 13 17:25:45 UTC 2009 i686 GNU/Linux

This problem may be related to #522949.
"TZ=Egypt date -d 'Dec 1 00:00:00 2037' prints UTC date."
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=522949
-- 
Tanaka Akira



Reply to: