On Wed, 5 Nov 2003, Matt Sisk wrote:

> Was there a compelling reason not to have a class method analagous to
> DefaultLocale() for timezones, such as DefaultTimezone()?

Nope, no particular reason.  But thinking about it, it seems like a bad
idea.  Locale is something that I would think the end user always wants to
set for themselves.  OTOH, the standard of "absent a time zone, we use
floating" makes it easy for people to write modules that use DateTime
stuff internally without having to worry about the user have set the
default time zone for their own code.

It strikes me as potentially dangerous action at a distance, because
setting the time zone can impact a _lot_ of calculations, whereas setting
the locale impacts nothing except presentation, which shouldn't be the
concern of CPAN modules using DateTime internally.

> DateTimes:
>
>   use DateTime;
>   use DateTime::Format::MySQL;
>
>   $F = 'DateTime::Format::MySQL';
>
>   $now = DateTime->now(time_zone => 'local');
>   print "now:  ", $now->datetime, "\n";
>   print "tz:   ", $now->time_zone_long_name, "\n";
>   $mdt = $F->format_datetime($now);
>   print "mdt:  $mdt\n";
>   $now = $F->parse_datetime($mdt);
>   print "now2: ", $now->datetime, "\n";
>   print "tz2:  ", $now->time_zone_long_name, "\n";
>   $now->set_time_zone('local');
>   print "now2: ", $now->datetime, "\n";
>   print "tz2:  ", $now->time_zone_long_name, "\n";
>
> In order to get symmetry, you have to first set_time_zone('UTC') to
> convert from 'floating', then set_time_zone('local') to get back to the
> original time.
>
> Am I going about this the wrong way?

No, this probably just needs some documentation in DT::F::MySQL about how
to handle the results of parsing.


-dave

/*=======================
House Absolute Consulting
www.houseabsolute.com
=======================*/

Reply via email to