* D. Barbier <[email protected]>, 2013-06-01, 19:12:
$ grep POT-Creation dummy.po
"POT-Creation-Date: 2013-06-01 17:39+0300\n"
$ date -R
Sat, 01 Jun 2013 17:39:37 +0200
Hello,
This one is already fixed in upstream SVN:
http://anonscm.debian.org/viewvc/po4a?view=revision&revision=2720
Thanks. I had a look at the current code, and I'm afraid it still
gets wrong results around the time DST begins or ends, for a few
reasons:
1) You call localtime() twice. But DST could start or end between the
two calls. (Admittedly that's not very likely to happen. :P)
2) You use Time::Local::timelocal(). As I understand it, this function
doesn't take the isdst flag into account, which means it could return
wrong value when that flag is required for disambiguation.
3) Reinterpreting GMT time as local time is not sound: you could cross
DST boundaries, or there could be two interpretations, or no
interpretations...
I've attached patch to fix this bug properly. :)
--
Jakub Wilk
Index: lib/Locale/Po4a/Po.pm
===================================================================
--- lib/Locale/Po4a/Po.pm (revision 2722)
+++ lib/Locale/Po4a/Po.pm (working copy)
@@ -157,12 +157,12 @@
# '%s' is not supported on Solaris and '%z' indicates
# "2006-10-25 19:36E. Europe Standard Time" on MS Windows.
sub timezone {
- my @g = gmtime();
- my @l = localtime();
+ my ($time) = @_;
+ my @l = localtime($time);
my $diff;
- $diff = floor(timelocal(@l)/60 +0.5);
- $diff -= floor(timelocal(@g)/60 +0.5);
+ $diff = floor(timegm(@l)/60 +0.5);
+ $diff -= floor($time/60 +0.5);
my $h = floor($diff / 60);
my $m = $diff%60;
@@ -172,7 +172,8 @@
sub initialize {
my ($self, $options) = (shift, shift);
- my $date = strftime("%Y-%m-%d %H:%M", localtime).timezone();
+ my $time = time;
+ my $date = strftime("%Y-%m-%d %H:%M", localtime($time)).timezone($time);
chomp $date;
# $options = ref($options) || $options;