Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 Sep 2000 08:06:42 +0100
From:      Mark Ovens <marko@freebsd.org>
To:        Joao Carlos Mendes Luis <jonny@jonny.eng.br>
Cc:        questions@freebsd.org
Subject:   Re: mktime(3) Y2K bug?
Message-ID:  <20000925080642.E252@parish>
In-Reply-To: <39CEC61F.DD8F23FB@jonny.eng.br>; from jonny@jonny.eng.br on Mon, Sep 25, 2000 at 12:27:27AM -0300
References:  <39CD8FD9.F2B7419@jonny.eng.br> <20000924115101.A252@parish> <39CE8C9E.D7FA5FAA@jonny.eng.br> <20000925010622.F255@parish> <39CEC61F.DD8F23FB@jonny.eng.br>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Sep 25, 2000 at 12:27:27AM -0300, Joao Carlos Mendes Luis wrote:
> AAAAAAAAAAAAAAAAAAAAAAARGHHHHHHHHHHHH!!!
> 
>   I found the reason for the "bug".  There will be NO 00:01 at Oct 1st
> in Brazil.  It´s the beginning of Daylight Savings, according to the
> current zoneinfo file!  Maybe we should just treat this as a feature,
> not as a bug...   ;-)
> 

I'd say it was a bug. From mktime(3):

   A positive or zero value for tm_isdst causes mktime() to presume
   initially that summer time (for example, Daylight Saving Time) is or
   is not in effect for the specified time, respectively. A negative value
   for tm_isdst causes the mktime() function to attempt to divine whether
   summer time is in effect for the specified time. The tm_isdst and
   tm_gmtoff members are forced to zero by timegm().

   [snip]

   Mktime() returns the specified calendar time; if the calendar time
   cannot be represented, it returns -1;

Surely mktime() should be able to work out that for t == 970358460 the
calendar time is 01:01:00 BRT+1 and not 00:01:00 BRT?

> Mark Ovens wrote:
> > 
> > On Sun, Sep 24, 2000 at 08:22:06PM -0300, Joao Carlos Mendes Luis wrote:
> > > I think I found more info.  This seens to happen only with the
> > > America/Sao_Paulo zoneinfo into /etc/localtime, and TZ not set.  If I
> > > change it to GMT+3, it works perfectly.  Mark, could you please test
> > > this at your machine?
> > >
> > 
> > Yes, it looks like the timezone file
> > (/usr/share/zoneinfo/America/Sao_Paulo) is broken/corrupt:
> > 
> > /usr/share/zoneinfo/America{127}# tzsetup Sao_Paulo
> > /usr/share/zoneinfo/America{128}# date
> > Sun 24 Sep 2000 21:01:45 BRT
> > /usr/share/zoneinfo/America{129}# /usr/mark/time
> > t = -1
> > Wed Dec 31 20:59:59 1969
> > /usr/share/zoneinfo/America{130}# tzsetup ../GMT
> > /usr/share/zoneinfo/America{131}# date
> > Mon 25 Sep 2000 00:05:20 GMT
> > /usr/share/zoneinfo/America{132}# /usr/mark/time
> > t = 970358460
> > Sun Oct  1 00:01:00 2000
> > /usr/share/zoneinfo/America{133}#
> > 
> > > Mark Ovens wrote:
> > > >
> > > > On Sun, Sep 24, 2000 at 02:23:37AM -0300, Joao Carlos Mendes Luis wrote:
> > > > > Hi,
> > > > >
> > > > >   Try the following piece of code:
> > > > >
> > > > > #include <time.h>
> > > > >
> > > > > main()
> > > > > {
> > > > >   struct tm tm;
> > > > >   time_t t;
> > > > >
> > > > >   bzero( &tm, sizeof tm );
> > > > >   tm.tm_sec = 0;
> > > > >   tm.tm_min = 1;
> > > > >   tm.tm_hour = 0;
> > > > >   tm.tm_mday = 1;
> > > > >   tm.tm_mon = 9;
> > > > >   tm.tm_year = 100;
> > > > >   tm.tm_isdst = -1;
> > > > >
> > > > >   t = mktime( &tm );
> > > > >   printf( "t = %ld\n", t );
> > > > >   printf( "%s", ctime( &t ) );
> > > > > }
> > > > >
> > > > >
> > > > > My results:
> > > > >
> > > > > FreeBSD:
> > > > >
> > > > > t = -1
> > > > > Wed Dec 31 20:59:59 1969
> > > > >
> > > >
> > > > Hmm, what version of FreeBSD? It works OK for me on 4.1-STABLE:
> > > >
> > > > /usr/marko{52}% cat > foo.c
> > > > #include <time.h>
> > > >
> > > > main()
> > > > {
> > > >   struct tm tm;
> > > >   time_t t;
> > > >
> > > >   bzero( &tm, sizeof tm );
> > > >   tm.tm_sec = 0;
> > > >   tm.tm_min = 1;
> > > >   tm.tm_hour = 0;
> > > >   tm.tm_mday = 1;
> > > >   tm.tm_mon = 9;
> > > >   tm.tm_year = 100;
> > > >   tm.tm_isdst = -1;
> > > >
> > > >   t = mktime( &tm );
> > > >   printf( "t = %ld\n", t );
> > > >   printf( "%s", ctime( &t ) );
> > > > }
> > > > /usr/marko{53}% cc -o foo foo.c
> > > > /usr/marko{54}% ./foo
> > > > t = 970354860
> > > > Sun Oct  1 00:01:00 2000
> > > > /usr/marko{55}%
> > > >
> > > > > Solaris:
> > > > >
> > > > > t = 970369260
> > > > > Sun Oct  1 00:01:00 2000
> > > > >
> > > > > Linux:
> > > > >
> > > > > t = -1
> > > > > Wed Dec 31 20:59:59 1969
> > > > >
> > > > >   If I change tm_year to 99, everything is ok.
> > > > >
> > > > >   Is this a bug, or just something stupid I can´t see at 2am without
> > > > > enough coffe?
> > > > >
> > > > >   I found this executing at(1) as "at 10/01/00", if that matters.
> > > > >
> > > > >   TIA,
> > > > >
> > > > >                                         Jonny
> > > > >
> > > > > --
> > > > > João Carlos Mendes Luís                 jonny@embratel.net.br
> > > > >   Networking Engineer                   jonny@jonny.eng.br
> > > > >  Internet via Embratel                        jcml@ieee.org
> > > > >
> > > > >
> > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org
> > > > > with "unsubscribe freebsd-questions" in the body of the message
> > > >
> > > > --
> > > >                 4.4 - The number of the Beastie
> > > > ________________________________________________________________
> > > > 51.44°N  FreeBSD - The Power To Serve http://www.freebsd.org
> > > > 2.057°W  My Webpage http://ukug.uk.freebsd.org/~mark
> > > > mailto:marko@freebsd.org                http://www.radan.com
> > >
> > > --
> > >
> > >                                         Jonny
> > >
> > > --
> > > João Carlos Mendes Luís                 jonny@embratel.net.br
> > >   Networking Engineer                   jonny@jonny.eng.br
> > >  Internet via Embratel                        jcml@ieee.org
> > 
> > --
> >                 4.4 - The number of the Beastie
> > ________________________________________________________________
> > 51.44°N  FreeBSD - The Power To Serve http://www.freebsd.org
> > 2.057°W  My Webpage http://ukug.uk.freebsd.org/~mark
> > mailto:marko@freebsd.org                http://www.radan.com
> 
> -- 
> 
>                                         Jonny
> 
> -- 
> João Carlos Mendes Luís                 jonny@embratel.net.br
>   Networking Engineer                   jonny@jonny.eng.br
>  Internet via Embratel			jcml@ieee.org
> 
> 
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-questions" in the body of the message

-- 
		4.4 - The number of the Beastie
________________________________________________________________
51.44°N  FreeBSD - The Power To Serve http://www.freebsd.org
2.057°W  My Webpage http://ukug.uk.freebsd.org/~mark
mailto:marko@freebsd.org                http://www.radan.com



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000925080642.E252>