Bug 134576 - Error: mktime() returns wrong GMT time for 2nd long hour on DST long day
Summary: Error: mktime() returns wrong GMT time for 2nd long hour on DST long day
Alias: None
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: glibc   
(Show other bugs)
Version: 3.0
Hardware: ia64
OS: Linux
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
Depends On:
TreeView+ depends on / blocked
Reported: 2004-10-04 18:57 UTC by Cindy
Modified: 2007-11-30 22:07 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2004-10-30 09:28:30 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

Description Cindy 2004-10-04 18:57:54 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET 
CLR 1.0.3705; .NET CLR 1.1.4322)

Description of problem:
When mktime() is called with 2nd long hour on the daylight saving's 
long day,  it returns the GMT time the same as the first hour on the 
long day even the tm_isdst is set to 0.

Note:  for the first hour --> tim_isdst is set to 1 (mktime works OK)
       for the second hour -> tim_isdst is set to 0 (mktime retunrs
       the same GMT time as the first hour instead of 3600 seconds

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1.  Check your system's daya light saving long day
2.  Write test program to call mktime() with your system;s long time
3.  Pass the first hour and second long hour to mktime()

Actual Results:  Check the return from mktime()
both hours return the same time

Expected Results:  The second hour should be 3600 seconds more than 
the first hour

Additional info:

Comment 1 Jakub Jelinek 2004-10-12 13:19:14 UTC
$ cat /tmp/mktime.c
#include <time.h>
#include <sys/time.h>
#include <stdio.h>
#include <stdlib.h>

int main (void)
  struct tm tm;
  char buf[120];
  time_t t;

  setenv ("TZ", "Europe/Prague", 1);
  tzset ();
  t = 1099181079;
  tm = *localtime (&t);
  if (strftime (buf, 120, "%a,  %d  %b  %Y  %H:%M:%S  %z", &tm))
    fputs (buf, stdout);
  printf (" isdst %d == %ld\n", tm.tm_isdst, (long) mktime (&tm));
  t = 1099184679;
  tm = *localtime (&t);
  if (strftime (buf, 120, "%a,  %d  %b  %Y  %H:%M:%S  %z", &tm))
    fputs (buf, stdout);
  printf (" isdst %d == %ld\n", tm.tm_isdst, (long) mktime (&tm));
  return 0;

$ gcc -o /tmp/mktime{,.c}; /tmp/mktime
Sun,  31  Oct  2004  02:04:39  +0200 isdst 1 == 1099181079
Sun,  31  Oct  2004  02:04:39  +0100 isdst 0 == 1099184679

Comment 2 Jakub Jelinek 2004-10-12 13:28:27 UTC
Can you provide a testcase?  The test I posted above shows things
work as they are supposed to.

Comment 3 Jakub Jelinek 2004-10-30 09:28:30 UTC
If you have a testcase that shows some bug, please reopen.

Note You need to log in before you can comment on or make changes to this bug.