in reply to setting TZ causes Date::Manip to report incorrect time
There are a library of DateTime modules now available that can help you with anything related to dates and times, including working with httpd logs, with databases and even with using your own date formats. DateTime offers both strftime and strptime, so you're never limited by existing format modules.
DateTime also does a good job of durations and never assumes there's 24 * 60 * 60 seconds in a day. A fault of most (if not all) previously existing date and time modules.
However, like Date::Manip, DateTime needs to find your local time zone from somewhere if you want to talk about 'local' dates and times. But if your machine doesn't already have the information DateTime needs, there's no need to worry. If you know where you are (and most of us do!) you should be setting it anyways.
If timezones don't matter, then there's always the 'floating' timezone. This zone just 'floats' your datetime until you allocate a time zone to it. Huh? Well, if you make a datetime for 5pm on Sept 9, 2003 but don't specify a timezone then it's 'floating'. One you $dt->set_timezone('SomeZone') then it becomes 5pm on Sept 9, 2003 in SomeZone. It doesn't change the time, just the zone its in. Now if you were to change from SomeZone to UTC (similar to GMT), it becomes some other time, depending on the offset of SomeZone to UTC.
All in all, the DateTime modules solve pretty much any problem to do with dates and times in perl. If you have a problem that it doesn't solve then you're in luck: the development group is very active and will listen to anything you need.
At this point I should point out that I am one of the lowly developers in the project, so I have a certain bias. Despite this, and thinking as objectivly as I can, I still think DateTime is the best solution for most date and time problems in perl.
You can contact the mailing list at datetime@perl.org, and can download the modules from CPAN.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: setting TZ causes Date::Manip to report incorrect time
by meonkeys (Chaplain) on Sep 09, 2003 at 19:14 UTC | |
by autarch (Hermit) on Sep 09, 2003 at 19:56 UTC | |
by BigLug (Chaplain) on Sep 10, 2003 at 04:04 UTC | |
by meonkeys (Chaplain) on Sep 10, 2003 at 21:27 UTC |