On Thu, Nov 03, 2005 at 01:52:39PM -0800, Mike Schilli wrote:
> Shouldn't parse_datetime() create a DateTime object with a floating time zone
> in this case?
I agree.
I ran up against a similar issue yesterday using
DateTime::Format::DateManip because it sets to the local timezone (as
determined by Date::Manip).
For example, I have a web form where events are created. A time and
location (where the event is located) need to be entered. When the
event date is entered it's assumed to be a time local to the location
of the event.
So I want to accept a floating time and then set its timezone based on
the timezone of the location.
So if my server is in US/Pacific:
use DateTime::Format::DateManip;
my $event_time = 'Monday at 9am';
my $event_location = 'America/Chicago';
my $dt = DateTime::Format::DateManip->parse_datetime($event_time);
print "Time = $dt\n";
$dt->set_time_zone( $event_location );
print "Time = $dt\n";
returns:
Time = 2005-10-31T09:00:00
Time = 2005-10-31T11:00:00
which might make some people in Chicago a bit upset when they show up
late to the event.
My solution was to set a floating time first, but seems like by
default the parsers should set a floating time zone.
my $dt = DateTime::Format::DateManip->parse_datetime($event_time);
$dt->set_time_zone( 'floating' );
By the way, I'm open to suggestion on better ways to parse free-form
time entries.
--
Bill Moseley
[EMAIL PROTECTED]