Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: setting TZ causes Date::Manip to report incorrect time

by Anonymous Monk
on Mar 11, 2022 at 06:57 UTC ( [id://11141994]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: setting TZ causes Date::Manip to report incorrect time
in thread setting TZ causes Date::Manip to report incorrect time

So I'll take your challenge and say .. I think its working, if you dig into how its intended to work. Using your exact example dataset, I reformatted it for Date::Manip. Some may have other opinions on how to set the date, but this is compact and for me easy to follow:
use strict; use warnings; use Date::Manip; my $dt1 = Date::Manip::Date->new(); my $dt2 = Date::Manip::Date->new(); $dt1->config("setdate","zone,Asia/Tokyo"); $dt2->config("setdate","zone,Asia/Calcutta"); $dt1->parse("20030502T07:53"); $dt2->parse("20030502T05:53"); if ( $dt1->cmp($dt2) ) { print "dt1 ftw!\n"; } else { print "dt2 ftw!\n"; } print $dt1->printf("dt1 %c %Z\n"); $dt1->convert("Asia/Calcutta"); print $dt1->printf("dt1 %c %Z\n"); print $dt2->printf("dt2 %c %Z\n");
Output is:
$ perl ./testdate dt1 ftw! dt1 Fri May 2 07:53:00 2003 JST dt1 Fri May 2 04:23:00 2003 IST dt2 Fri May 2 05:53:00 2003 IST

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11141994]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2026-04-22 12:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.