Skip Menu |

This queue is for tickets about the Date-Manip CPAN distribution.

Report information
The Basics
Id: 62540
Status: resolved
Priority: 0/
Queue: Date-Manip

People
Owner: Nobody in particular
Requestors: fancyrabbit [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 6.14
Fixed in: (no value)



Subject: Asia/Shanghai does not properly represent GMT+8
normally, Asia/Shanghai and Asia/Hong_Kong represents the same timezone: +0800 but it seems that Date::Manip improperly translates Asia/Shanghai to 'CST'(China standard time), which has the same abbreviation of Central standard time in north america which is -0600 and confused with them. $ perl -v This is perl, v5.8.8 built for x86_64-linux-thread-multi $ uname -a Linux zjm_20_201 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux $ cat date.pl use Date::Manip; use Data::Dumper; print Dumper UnixDate('today 00:00', '%Y %b %d %H:%M:%S %z'); print Dumper UnixDate('now', '%Y %b %d %H:%M:%S %z'); print Dumper Date_TimeZone(); $ TZ='Asia/Shanghai' perl date.pl $VAR1 = '2010 Oct 29 00:00:00 -0600'; $VAR1 = '2010 Oct 29 13:43:40 -0600'; $VAR1 = 'CST'; $ TZ='Asia/Hong_Kong' perl date.pl $VAR1 = '2010 Oct 29 00:00:00 +0800'; $VAR1 = '2010 Oct 29 13:43:40 +0800'; $VAR1 = 'HKT';
From: fancyrabbit [...] gmail.com
another problem is when setting $ENV{'TZ'} to 'HKT' or 'Asia/Hong_Kong', the times are different. $ TZ='Asia/Hong_Kong' perl date.pl $VAR1 = '2010 Oct 29 00:00:00 +0800'; $VAR1 = '2010 Oct 29 16:50:07 +0800'; $VAR1 = 'HKT'; $ TZ='HKT' perl date.pl $VAR1 = '2010 Oct 29 00:00:00 +0800'; $VAR1 = '2010 Oct 29 08:50:29 +0800'; $VAR1 = 'HKT'; 在 2010-十月-29 01:57:25 星期五 时,fancyrabbit 写到: Show quoted text
> normally, Asia/Shanghai and Asia/Hong_Kong represents the same
timezone: Show quoted text
> +0800 > but it seems that Date::Manip improperly translates Asia/Shanghai to > 'CST'(China standard time), which has the same abbreviation of Central > standard time in north america which is -0600 and confused with them. > > $ perl -v > This is perl, v5.8.8 built for x86_64-linux-thread-multi > > $ uname -a > Linux zjm_20_201 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 > x86_64 x86_64 x86_64 GNU/Linux > > $ cat date.pl > use Date::Manip; > use Data::Dumper; > print Dumper UnixDate('today 00:00', '%Y %b %d %H:%M:%S %z'); > print Dumper UnixDate('now', '%Y %b %d %H:%M:%S %z'); > print Dumper Date_TimeZone(); > > $ TZ='Asia/Shanghai' perl date.pl > $VAR1 = '2010 Oct 29 00:00:00 -0600'; > $VAR1 = '2010 Oct 29 13:43:40 -0600'; > $VAR1 = 'CST'; > > $ TZ='Asia/Hong_Kong' perl date.pl > $VAR1 = '2010 Oct 29 00:00:00 +0800'; > $VAR1 = '2010 Oct 29 13:43:40 +0800'; > $VAR1 = 'HKT';
The problems has to do with the horribly incomplete way that Date::Manip 5.xx works with timezones. Because you're running perl 5.8, you are running the 5.xx Date::Manip release (Date-Manip-6.15 contains two versions of Date::Manip - the 5.xx release and the 6.xx release since the 6.xx release does not run on perl 5.6/5.8). Date::Manip 5.xx never recognized TZ names (i.e. Asia/Shanghai)... it only recognized specific abbreviations (i.e. CST). But one of the ways it determines the timezone is to use the date command which DOES recognize them. So, by setting the environment variable to Asia/Shanghai, the date command returns something with the CST abbreviation. The CST abbrevation can apply to multiple timezones... specifically America/Chicago (which is -0600) which is what is getting returned. Unfortunately, this is a huge problem, and is the primary reason that Date::Manip was completely rewritten. If you can upgrade perl to 5.10 (or higher), things will work as expected for you. Alternately, you can set "TZ=+0800" and it'll work better, but even then, you're not going to always get the results you want. You have to recognize that timezone handling in Date::Manip 5.xx is broken, and there's no way to make it do the right thing in all cases.