From owner-freebsd-bugs@FreeBSD.ORG Sun Jun 29 23:50:21 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 C6B7737B401 for ; Sun, 29 Jun 2003 23:50:21 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5BD1343F85 for ; Sun, 29 Jun 2003 23:50:21 -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 h5U6oLUp078685 for ; Sun, 29 Jun 2003 23:50:21 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h5U6oLbG078678; Sun, 29 Jun 2003 23:50:21 -0700 (PDT) Date: Sun, 29 Jun 2003 23:50:21 -0700 (PDT) Message-Id: <200306300650.h5U6oLbG078678@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: "Nick Triantos" Subject: RE: 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: Nick Triantos List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Jun 2003 06:50:22 -0000 The following reply was made to PR bin/53899; it has been noted by GNATS. From: "Nick Triantos" To: "'Barry Pederson'" , Cc: Subject: RE: bin/53899: mktime gives wrong result in Central timezone Date: Sun, 29 Jun 2003 23:47:39 -0700 I found out the hard way that this is apparently not a bug, but a feature. On *BSD systems, for some weird reason, mktime() does not call localtime(). I had submitted a patch to fix this, but it got removed because there are apparently some applications that depend on this unusual behaviour. To work around the problem, call localtime() manually. -Nick -----Original Message----- From: owner-freebsd-bugs@freebsd.org [mailto:owner-freebsd-bugs@freebsd.org] On Behalf Of Barry@FreeBSD.org Sent: Sunday, June 29, 2003 10:06 AM To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/53899: mktime gives wrong result in Central timezone >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: _______________________________________________ freebsd-bugs@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-bugs To unsubscribe, send any mail to "freebsd-bugs-unsubscribe@freebsd.org"