[Po4a-commits] "po4a/lib/Locale/Po4a Po.pm,1.66,1.67"
Nicolas FRANCOIS
nekral-guest at alioth.debian.org
Tue Oct 31 00:06:19 CET 2006
Update of /cvsroot/po4a/po4a/lib/Locale/Po4a
In directory alioth:/tmp/cvs-serv5479/lib/Locale/Po4a
Modified Files:
Po.pm
Log Message:
Do not use the %z format with strftime, it is not portable. Compute our
own numerical timezone.
Index: Po.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/Po.pm,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -d -r1.66 -r1.67
--- Po.pm 30 Oct 2006 23:00:49 -0000 1.66
+++ Po.pm 30 Oct 2006 23:06:17 -0000 1.67
@@ -82,7 +82,7 @@
use Carp qw(croak);
use File::Path; # mkdir before write
use File::Copy; # move
-use POSIX qw(strftime);
+use POSIX qw(strftime floor);
use Encode;
@@ -117,9 +117,26 @@
return $self;
}
+# Return the numerical timezone (e.g. +0200)
+# The %z format of strftime is not portable.
+# For example, it indicates "2006-10-25 19:36E. Europe Standard Time" on
+# MS Windows.
+sub timezone {
+ my @g = gmtime();
+ my @l = localtime();
+
+ my $diff = floor(strftime("%s", @l)/60 +0.5) - floor(strftime("%s", @g)/60 + 0.5);
+
+ my $h = floor($diff / 60) + $l[8]; # $l[8] indicates if we are currently
+ # in a daylight saving time zone
+ my $m = $diff%60;
+
+ return sprintf "%+03d%02d\n", $h, $m;
+}
+
sub initialize {
my ($self, $options) = (shift, shift);
- my $date = strftime("%Y-%m-%d %H:%M%z", localtime);
+ my $date = strftime("%Y-%m-%d %H:%M", localtime).timezone();
chomp $date;
# $options = ref($options) || $options;
More information about the Po4a-commits
mailing list