Bug 134576

Summary: Error: mktime() returns wrong GMT time for 2nd long hour on DST long day
Product: Red Hat Enterprise Linux 3 Reporter: Cindy <cindy.chang>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED WORKSFORME QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: 3.0   
Target Milestone: ---   
Target Release: ---   
Hardware: ia64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-10-30 09:28:30 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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
       more)


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

How reproducible:
Always

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.