On Tue, Oct 03, 2006 at 01:57:29PM -0700, Bill Moseley wrote: > $ perl -l dt.pl 'Dec 3, 2006 9am' > Sun, Dec 3 2006 8:00 AM PST
What time is: Dec 3, 2006 9am PDT ? (noting that it's PST in December) Using Manip is nice because it allows a wide range of input values ('first Tuesday in December'). But, it's some scary code and seems to be a bit broken with regard to DST. Any other options for somewhat free-form date parsing other that Date::Manip? BTW: DateTime::Format::DateManip does this: return undef unless @bits; my @args = merge_lists([qw( year month day hour minute second time_zone )], [EMAIL PROTECTED]); # Construct the DateTime object and use the offset timezone my $dt = DateTime->new(@args); # See if there is a better timezone to use my $dt_tz = $class->get_dt_timezone($dm_tz); # Apply the final time zone if (defined $dt_tz) { $dt->set_time_zone($dt_tz); } return $dt; First, since a timezone is used to create the DateTime object, it's not "applying the final time zone", it's *changing* the final time zone. But, that seems a bit moot because of.... Seems to assume the current timezone: $ perl -MDate::Manip -le 'print UnixDate("Oct 3, 2006 9am", "%Z %Y %m %d %H %M %S %z " )' PDT 2006 10 03 09 00 00 -0700 But, push the date over the DST change and: 'print UnixDate("Dec 3, 2006 9am", "%Z %Y %m %d %H %M %S %z " )' PDT 2006 12 03 09 00 00 -0700 That sure looks wrong. Can't use that time zone when creating the DateTime object -- although could use US/Pacific and it would work. But.... 'print UnixDate("Dec 3, 2006 9am PST", "%Z %Y %m %d %H %M %S %z " )' PDT 2006 12 03 10 00 00 -0700 Crap. -- Bill Moseley [EMAIL PROTECTED]