bin/53899: mktime gives wrong result in Central timezone

Barry Pederson bp at barryp.org
Sun Jun 29 11:50:14 PDT 2003


The following reply was made to PR bin/53899; it has been noted by GNATS.

From: Barry Pederson <bp at barryp.org>
To: freebsd-gnats-submit at FreeBSD.org
Cc:  
Subject: Re: bin/53899: mktime gives wrong result in Central timezone
Date: Sun, 29 Jun 2003 13:46:49 -0500

 Here's a C equivalent to the Perl script
 that demonstrates the problem.  Compile with:
 
     gcc -o tzdemo tzdemo.c
 
 and alter the tzdemo.sh script to run ./tzdemo
 instead of tzdemo.pl
 
 The output is the same as before, which should
 rule out this being a Perl (or Python) problem.
 
 -------- tzdemo.c ------------
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
 
 int main(int argc, char **argv)
      {
      struct tm test_gm;
      time_t result;
      time_t test_time = 1055176982;
 
      memset(&test_gm, 0, sizeof(test_gm));
      test_gm.tm_sec  = 2;
      test_gm.tm_min  = 43;
      test_gm.tm_hour = 16;
      test_gm.tm_mday = 9;
      test_gm.tm_mon  = 5;
      test_gm.tm_year = 103;
      test_gm.tm_wday = 1;
      test_gm.tm_yday = 159;
      test_gm.tm_isdst = 0;
 
      result = mktime(&test_gm);
 
      printf("%s %d %d\n", getenv("TZ"), (int) result,
           ((int)(result-test_time))/3600);
 
      return 0;
      }
 ---------------------------
 


More information about the freebsd-bugs mailing list