Bug 74042 - Perl-5.6.1 does not handle timezone properly
Perl-5.6.1 does not handle timezone properly
Status: Closed FIXED
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s)
Latest
Any Any
: Normal Affects Only Me
Assigned To: Anton Berezin
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2004-11-17 15:40 UTC by sp
Modified: 2005-02-02 09:57 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description sp 2004-11-17 15:40:31 UTC
	Perl POSIX::strftime does not handle daylight saving correctly.
	Detail are in "How-To-Repeat".
	It's probably problem of Perl.
	Repeated on 4.10-RELEASE

Fix: 

Unknown.
How-To-Repeat: 
$ cc -Wall t.c
$ cat t.c # - C program
#include <stdio.h>
#include <time.h>
static void
printtime(time_t t) {
  char buf[256];
  strftime(buf,sizeof(buf),"%F %T %z %Z\n",localtime(&t));
  printf(buf);
}
int
main(void)
{
  time_t t = time(NULL);
  t = t - t%(24*3600);
  printtime(t);
  printtime(t-30*24*3600);
  return 0;
}
$ cat t.pl # Perl program doing same thing
#!/usr/bin/perl -w
use strict;
use POSIX qw();
my $time = time;
$time = $time - ($time%(24*3600));
my @d0 = localtime($time);
print(POSIX::strftime("%F %T %z %Z\n",@d0));
my @d1 = localtime($time-30*24*3600);
print(POSIX::strftime("%F %T %z %Z\n",@d1));
__END__
$ ./a.out
2004-11-17 03:00:00 +0300 MSK
2004-10-18 04:00:00 +0400 MSD
$ perl -w t.pl
2004-11-17 03:00:00 +0300 MSK
2004-10-18 04:00:00 +0300 MSK
$ echo $LANG
ru_RU.KOI8-R
$ echo $LC_ALL
ru_RU.KOI8-R
$

Perl's strftime does not provide right timezone offset and name for
daylight saving times. C program works correctly (first date is in
"winter" time, second in "daylight saving").
Comment 1 Anton Berezin freebsd_committer 2004-11-17 15:46:03 UTC
Responsible Changed
From-To: freebsd-ports-bugs->tobez

Take.
Comment 2 tobez 2004-11-17 15:50:07 UTC
On Wed, Nov 17, 2004 at 06:36:17PM +0300, Sergey Potapov wrote:

> $ echo $LANG
> ru_RU.KOI8-R
> $ echo $LC_ALL
> ru_RU.KOI8-R

These are irrelevant.

> $ ./a.out
> 2004-11-17 03:00:00 +0300 MSK
> 2004-10-18 04:00:00 +0400 MSD
> $ perl -w t.pl
> 2004-11-17 03:00:00 +0300 MSK
> 2004-10-18 04:00:00 +0300 MSK

What are your timezone settings?

tobez@hrum ~/_> ./t
2004-11-17 01:00:00 +0100 CET
2004-10-18 02:00:00 +0200 CEST
tobez@hrum ~/_> perl t.pl 
2004-11-17 01:00:00 +0100 CET
2004-10-18 02:00:00 +0200 CEST
tobez@hrum ~/_> TZ=Europe/Moscow ./t
2004-11-17 03:00:00 +0300 MSK
2004-10-18 04:00:00 +0400 MSD
tobez@hrum ~/_> TZ=Europe/Moscow perl t.pl
2004-11-17 03:00:00 +0300 MSK
2004-10-18 04:00:00 +0400 MSD

I do not seem to be able to reproduce your problem.

\Anton.
-- 
The moronity of the universe is a monotonically increasing function. --
Jarkko Hietaniemi
Comment 3 Anton Berezin freebsd_committer 2005-02-02 09:57:04 UTC
State Changed
From-To: open->closed

Fixed in the recent update of lang/perl5.