Date: Sun, 29 Jun 2003 23:50:21 -0700 (PDT) From: "Nick Triantos" <nick@triantos.com> To: freebsd-bugs@FreeBSD.org Subject: RE: bin/53899: mktime gives wrong result in Central timezone Message-ID: <200306300650.h5U6oLbG078678@freefall.freebsd.org>
index | next in thread | raw e-mail
The following reply was made to PR bin/53899; it has been noted by GNATS.
From: "Nick Triantos" <nick@triantos.com>
To: "'Barry Pederson'" <bp@barryp.org>,
<FreeBSD-gnats-submit@FreeBSD.org>
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"
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200306300650.h5U6oLbG078678>
