On 2 Jul 2004, at 7:13 AM, Max Campos wrote:
All I want is simple "local time" date time manipulation without having to deal with timezones.

However, as illustrated below, I'm getting some weird (GMT?) results. Is this correct behavior? I'm using stock Red Hat 9 perl 5.8.0.

=====================
use DateTime;

print "DATE:  " . `date`;
print "DTNOW: " . DateTime->now . "\n";

DateTime->now() returns a UTC time unless given a time zone. Consider using:
$dt = DateTime->now( time_zone => 'local' );


print "DTABS: " . new DateTime(month => 7, day => 1, year => 2004, hour => 14) . "\n";

On the other hand, DateTime->new() returns the local time zone unless otherwise instructed.


Dave, can you enlighten me as to why this is the case? Shouldn't all constructors that don't have a time_zone attribute assume the same? (Which I'd prefer to be local if we can get it)

While talking about local time zones, I'd like to again ask that during the install stage, the local zone can be set/confirmed. I'm sure you had a good reason not to do that, but I can't remember it.

I'd also like to see a class based (rather than object based) ability to set the local time zone, probably through the import:

use DateTime local => 'Australia/Melbourne';

Then all constructors would use that as the local (default) zone.

Cheers!
Rick



Senior Developer
PrintSupply - Print Procurement & Supply Management
18 Greenaway Street VIC 3105
Tel: (03) 9850 3255
Fx: (03) 9850 3277
http://www.printsupply.com.au/




Reply via email to