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

Bug#36775: incompatible mktime() behavior under Debian Linux 2.2.1 (formerly used 2.033)



Package: libc6
Version: 2.0.7.19981211

The version of mktime() in Debian 2.2.1 has incompatible behavior
from that of Debian 2.0.33.  Note that 2.2.1 uses  /lib/libc-2.0.7.so.


In particular, mktime() under 2.0.33 had the following behavior
which is described in man pages on Solaris and IRIX (and implemented
there as well):

	If tm_isdst is positive, the original values are assumed to be in
	the alternate timezone.  If it turns out that the alternate timezone
	is not valid for the computed calendar time, then the components are
	adjusted to the main timezone.  Likewise, if tm_isdst is zero, the original
	values are assumed to be in the main timezone and are converted to the
	alternate timezone if the main timezone is not valid.  If tm_isdst is
	negative, the correct timezone is determined and the components are not
	adjusted.

The new mktime() under 2.2.1 does not implement this behavior since it
no longer adjusts the time in accordance with the tm_isdst setting.
It does, however, adjust the tm_isdst value itself.

I am attaching a program with output for illustration.  

Is there a reason for this new non-compatible behavior?

Thanks much,

	Gerry Wiener	(303)497-8417  Email: gerry@ucar.edu
	National Center for Atmospheric Research
	P.O. Box 3000
	Boulder, Co
	80307-3000



------------------------------------------------------------
/*
 * Module: time_test.c
 *
 * Author: Gerry Wiener
 *
 * Date:   4/21/99
 *
 * Description:
 *     
 */

#include <time.h>
#include <sys/time.h>

void print_tm(struct tm *tms)
{
  printf("year: %d\n", tms->tm_year);
  printf("mon: %d\n", tms->tm_mon);
  printf("yday: %d\n", tms->tm_yday);
  printf("mday: %d\n", tms->tm_mday);
  printf("wday: %d\n", tms->tm_wday);
  printf("hour: %d\n", tms->tm_hour);
  printf("min: %d\n", tms->tm_min);
  printf("sec: %d\n", tms->tm_sec);
  printf("isdst: %d\n", tms->tm_isdst);
}


main(int argc, char **argv)
{
  time_t tim;
  struct tm tms;

  tms.tm_year = 99;
  tms.tm_mon = 4;
  tms.tm_mday = 21;
  tms.tm_hour =12;
  tms.tm_min = 0;
  tms.tm_sec = 0;
  tms.tm_wday = 0;
  tms.tm_yday = 0;
  tms.tm_isdst = 0; 

  printf("\noriginal structure\n");
  print_tm(&tms);
  tim = mktime(&tms);
  printf("\nReturn: tim is %d, isdst is %d\n", tim, tms.tm_isdst);
  print_tm(&tms);

  tms.tm_year = 99;
  tms.tm_mon = 4;
  tms.tm_mday = 21;
  tms.tm_hour =12;
  tms.tm_min = 0;
  tms.tm_sec = 0;
  tms.tm_wday = 0;
  tms.tm_yday = 0;
  tms.tm_isdst = 1; 
  
  printf("\noriginal structure\n");
  print_tm(&tms);
  tim = mktime(&tms);
  printf("\nReturn: tim is %d, isdst is %d\n", tim, tms.tm_isdst);
  print_tm(&tms);

  tms.tm_year = 99;
  tms.tm_mon = 4;
  tms.tm_mday = 21;
  tms.tm_hour =12;
  tms.tm_min = 0;
  tms.tm_sec = 0;
  tms.tm_wday = 0;
  tms.tm_yday = 0;
  tms.tm_isdst = -1; 
  
  printf("\noriginal structure\n");
  print_tm(&tms);
  tim = mktime(&tms);
  printf("\nReturn: tim is %d, isdst is %d\n", tim, tms.tm_isdst);
  print_tm(&tms);

}

------------------------------------------------------------
Output under Debian 2.0.33 (agrees with output under Solaris) - note
the return tim value:


original structure
year: 99
mon: 4
yday: 0
mday: 21
wday: 0
hour: 12
min: 0
sec: 0
isdst: 0

[***this return value is what I am expecting] Return: tim is 927313200, isdst is 1
year: 99
mon: 4
yday: 140
mday: 21
wday: 5
[**this is expected as well] hour: 13
min: 0
sec: 0
isdst: 1

original structure
year: 99
mon: 4
yday: 0
mday: 21
wday: 0
hour: 12
min: 0
sec: 0
isdst: 1

Return: tim is 927309600, isdst is 1
year: 99
mon: 4
yday: 140
mday: 21
wday: 5
hour: 12
min: 0
sec: 0
isdst: 1

original structure
year: 99
mon: 4
yday: 0
mday: 21
wday: 0
hour: 12
min: 0
sec: 0
isdst: -1

Return: tim is 927309600, isdst is 1
year: 99
mon: 4
yday: 140
mday: 21
wday: 5
hour: 12
min: 0
sec: 0
isdst: 1

------------------------------------------------------------
Output under Debian 2.2.1 (disagrees with 2.0.33 and Solaris output) - note
the return tim value:


original structure
year: 99
mon: 4
yday: 0
mday: 21
wday: 0
hour: 12
min: 0
sec: 0
isdst: 0

[**I didn't expect this] Return: tim is 927309600, isdst is 1
year: 99
mon: 4
yday: 140
mday: 21
wday: 5
[**I didn't expect this] hour: 12
min: 0
sec: 0
isdst: 1

original structure
year: 99
mon: 4
yday: 0
mday: 21
wday: 0
hour: 12
min: 0
sec: 0
isdst: 1

Return: tim is 927309600, isdst is 1
year: 99
mon: 4
yday: 140
mday: 21
wday: 5
hour: 12
min: 0
sec: 0
isdst: 1

original structure
year: 99
mon: 4
yday: 0
mday: 21
wday: 0
hour: 12
min: 0
sec: 0
isdst: -1

Return: tim is 927309600, isdst is 1
year: 99
mon: 4
yday: 140
mday: 21
wday: 5
hour: 12
min: 0
sec: 0
isdst: 1





Reply to: