Subject: misc/22221: Chicago time zone file problem
To: None <gnats-bugs@gnats.netbsd.org>
From: None <joe@laffeycomputer.com>
List: netbsd-bugs
Date: 07/22/2003 11:52:08
>Number:         22221
>Category:       misc
>Synopsis:       Chicago time zone file problem
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    misc-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jul 22 16:53:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        NetBSD 1.6.1
>Organization:
	Joe Laffey
>Environment:
	
	
System: NetBSD raw.laffeycomputer.com 1.6.1 NetBSD 1.6.1 (TOTALLY_RAW_v5) #0: Mon Mar 10 16:37:14 CST 2003 joe@raw.porksteak.com:/usr/src/sys/arch/i386/compile/TOTALLY_RAW_v5 i386
Architecture: i386
Machine: i386
>Description:
	When the localtime is set to Chicago (or central) the global var
	timezone is set to 18000 after a call to localtime. For this TZ
	it should be 21600 (-5GMT). Other timezones seems to work fine.

	I have verified this on two x86 boxen and one macppc box. All 1.6.x
>How-To-Repeat:

#include        <sys/types.h>
#include        <time.h>
#include        <stdio.h>
#include        <string.h>
#include        <stdlib.h>
#include        <unistd.h>

int main(void)
{
        struct  tm *p;
        int     offset;
        time_t t;

        t = time(NULL);
        p=localtime(&t);
        offset= -(int)timezone;

        if (p->tm_isdst > 0)
               offset += 60*60;
        if (offset % 60)
        {
                offset=0;
                p=gmtime(&t);
        }
        offset /= 60;

        offset = (offset % 60) + offset / 60 * 100;

        printf("offset:%+05d\n", offset);
        printf("timezone:%d\n", (int)timezone);


        return 0;
}

When run this code produces:

[10:25pm]host ~> ./a.out
offset:-0400
timezone:18000
[10:25pm]host ~> date
Sat Jul 19 22:25:43 CDT 2003


>Fix:

Creating a zoneinfo file that contains only the follow works fine:
Rule    US      1987    max     -       Apr     Sun>=1  2:00    1:00    D
Rule    US      1967    max     -       Oct     lastSun 2:00    0       S

Zone America/Chicago    -5:50:36 -      LMT     1883 Nov 18 12:00
                        -6:00   US      C%sT


I am not sure why the default zoneinfo file is not working. This could be a
bug in the input file to zic, or in zic itself.
>Release-Note:
>Audit-Trail:
>Unformatted:
 	Chicago (Central) TZ file has wrong global var timezone value.