From nobody@FreeBSD.ORG Mon Sep 20 10:23:11 1999
Return-Path: <nobody@FreeBSD.ORG>
Received: by hub.freebsd.org (Postfix, from userid 32767)
	id E4E7415390; Mon, 20 Sep 1999 10:23:10 -0700 (PDT)
Message-Id: <19990920172310.E4E7415390@hub.freebsd.org>
Date: Mon, 20 Sep 1999 10:23:10 -0700 (PDT)
From: duwde@elitenet.com.br
Sender: nobody@FreeBSD.ORG
To: freebsd-gnats-submit@freebsd.org
Subject: mktime() fails (returns -1) on some dates.
X-Send-Pr-Version: www-1.0

>Number:         13862
>Category:       misc
>Synopsis:       mktime() fails (returns -1) on some dates.
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Sep 20 10:30:01 PDT 1999
>Closed-Date:    Mon Sep 20 23:58:18 PDT 1999
>Last-Modified:  Mon Sep 20 23:58:50 PDT 1999
>Originator:     Fabio Dias
>Release:        2.2.8-RELEASE (kernel 2.2.8-STABLE)
>Organization:
EliteNet ISP
>Environment:
FreeBSD cosmic.elitenet.com.br 2.2.8-STABLE FreeBSD 2.2.8-STABLE #0: Thu Sep 16 13:57:41 EST 1999     root@cosmic.elitenet.com.br:/usr/src/sys/compile/COSMIC  i386

>Description:
When using some specific dates, mktimes() is unable to return the
real time_t and returns -1.

>How-To-Repeat:
/*
   Try this, there seems to be a problem in mktime(), using 2.2.8-RELEASE.
   mktime() doesn't work when using dates like (day/month/year):
   03/10/1999 - 16/10/1994 - and others...

                                Duwde <duwde@elitenet.com.br>
*/

#include <stdio.h>
#include <time.h>
#include <string.h>

int main(int argc, char **argv)
{
time_t timet_x;
struct tm tm_x, *tm_px=&tm_x;

memset(tm_px,(int)NULL,sizeof(tm_x));
tm_px->tm_mday=3;       /* 03 */
tm_px->tm_mon=9;        /* 10 */
tm_px->tm_year=99;      /* 1999 */

if ((timet_x=mktime(tm_px)) == -1)
        {
        printf("mktime() returned -1\n");
        printf("asctime(tm_px) -> %s\n",asctime(tm_px));
        printf("ctime(&timet_x) -> %s\n",ctime(&timet_x));
        }
        else printf("everything is ok...\n");

return (int)0;

>Fix:
Fix the mktime()

>Release-Note:
>Audit-Trail:

From: Ruslan Ermilov <ru@ucb.crimea.ua>
To: duwde@elitenet.com.br
Cc: freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: misc/13862: mktime() fails (returns -1) on some dates.
Date: Mon, 20 Sep 1999 21:17:03 +0300

 On Mon, Sep 20, 1999 at 10:23:10AM -0700, duwde@elitenet.com.br wrote:
 > 
 > >How-To-Repeat:
 > /*
 >    Try this, there seems to be a problem in mktime(), using 2.2.8-RELEASE.
 >    mktime() doesn't work when using dates like (day/month/year):
 >    03/10/1999 - 16/10/1994 - and others...
 > 
 >                                 Duwde <duwde@elitenet.com.br>
 > */
 
 % uname -v
 FreeBSD 2.2.8-RELEASE #2: Wed Dec 23 20:01:04 EET 1998     root@relay.fil05.ucb.crimea.ua:/usr/src/sys/compile/FIL05
 % ./a
 everything is ok...
 
 It works on 2.2.1-RELEASE and 3.2-STABLE boxes as well.
 Any additional info?
 
 
 -- 
 Ruslan Ermilov		Sysadmin and DBA of the
 ru@ucb.crimea.ua	United Commercial Bank,
 ru@FreeBSD.org		FreeBSD committer,
 +380.652.247.647	Simferopol, Ukraine
 
 http://www.FreeBSD.org	The Power To Serve
 http://www.oracle.com	Enabling The Information Age
 

From: Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
To: Fabio Dias <duwde@elitenet.com.br>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: misc/13862: mktime() fails (returns -1) on some dates.
Date: Mon, 20 Sep 1999 20:39:59 -0400 (EDT)

 <<On Mon, 20 Sep 1999 22:27:29 +0200, Fabio Dias <duwde@elitenet.com.br> said:
 
 > My timezone is America -> Brazil -> SE ! (EST)
 
 The fact that your problem is timezone-dependent should have given you
 a clue.
 
 The time you have specified (midnight) does not exist in your timezone
 on that date, due to the switch over to (or from) summer time.  Thus,
 mktime() is correct to return an error.  If you retry your request
 with tm_isdst set to -1, mktime() will attempt to guess whether you
 mean standard time or summer (daylight savings) time -- but there are
 still times which are impossible to resolve.
 
 Most other countries switch at times other than midnight.  You might
 find the results less surprising if you updated your timezone files to
 more recent ones which reflect the latest legal time changes in Brazil.
 
 In sum: there is no bug here.
 
 -GAWollman
 
 
State-Changed-From-To: open->closed 
State-Changed-By: sheldonh 
State-Changed-When: Mon Sep 20 23:58:18 PDT 1999 
State-Changed-Why:  
Known timezone-related issue. 
>Unformatted:
