From owner-freebsd-bugs@FreeBSD.ORG Sun Jun 29 10:10:10 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7E72737B401 for ; Sun, 29 Jun 2003 10:10:10 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 807CC44011 for ; Sun, 29 Jun 2003 10:10:09 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h5THA9Up096855 for ; Sun, 29 Jun 2003 10:10:09 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h5THA9vs096854; Sun, 29 Jun 2003 10:10:09 -0700 (PDT) Resent-Date: Sun, 29 Jun 2003 10:10:09 -0700 (PDT) Resent-Message-Id: <200306291710.h5THA9vs096854@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Barry Pederson Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CB4B237B401 for ; Sun, 29 Jun 2003 10:06:04 -0700 (PDT) Received: from eden.barryp.org (host-150-32-220-24.midco.net [24.220.32.150]) by mx1.FreeBSD.org (Postfix) with ESMTP id 189CE4400F for ; Sun, 29 Jun 2003 10:06:04 -0700 (PDT) (envelope-from barryp@eden.barryp.org) Received: from barryp by eden.barryp.org with local (Exim 4.20) id 19Wfcp-000G0j-3H for FreeBSD-gnats-submit@freebsd.org; Sun, 29 Jun 2003 12:06:03 -0500 Message-Id: Date: Sun, 29 Jun 2003 12:06:03 -0500 From: Barry@FreeBSD.org, "Pederson To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/53899: mktime gives wrong result in Central timezone X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Barry Pederson List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Jun 2003 17:10:11 -0000 >Number: 53899 >Category: bin >Synopsis: mktime gives wrong result in Central timezone >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Jun 29 10:10:08 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Barry Pederson >Release: FreeBSD 4.8-RELEASE i386 >Organization: >Environment: System: FreeBSD eden.barryp.org 4.8-RELEASE FreeBSD 4.8-RELEASE #0: Sat Apr 5 12:35:50 CST 2003 barryp@eden.barryp.org:/usr/obj/usr/src/sys/BARRYP i386 >Description: The mktime function seems to give an incorrect result when the timezone is set to US Central time. I first noticed this when running Zope3 (Python) unittests, but can also demonstrate the problem using Perl. >How-To-Repeat: Execute mktime() with the same parameters, but vary the TZ enviroment variable. Here is a shell script and a perl script to demonstrate: ------ tzdemo.sh ----------- #!/bin/sh for tz in 'EST5EDT' 'CST6CDT' 'MST7MDT' 'PST8PDT' do export TZ=$tz; /usr/bin/env perl tzdemo.pl $tz done ---------------------------- ------ tzdemo.pl ----------- #!/usr/bin/env perl use POSIX; # An arbitrary unix timestamp and its # gmtime() equivalent. # $test_time = 1055176982; @test_gm = (2, 43, 16, 9, 5, 103, 1, 159, 0); # You could also say: # # @test_gm = gmtime($test_time); # Convert test time back to a unix timestamp, but since # mktime() assumes localtime, the result should vary # according to the current timezone setting # $result = mktime(@test_gm); # Calculate the difference, in hours, between what mktime() # came up with for a local value and the initial GMT time # we started with. # $diff = ($result - $test_time) / 3600; print "$ARGV[0] $result $diff\n"; ---------------------------- The expected output is: EST5EDT 1055194982 5 CST6CDT 1055198582 6 MST7MDT 1055202182 7 PST8PDT 1055205782 8 The actual output I get is: EST5EDT 1055194982 5 CST6CDT 1055194982 5 MST7MDT 1055202182 7 PST8PDT 1055205782 8 The second line (CST6CDT) should not have the same numbers. >Fix: >Release-Note: >Audit-Trail: >Unformatted: