I know traditional convention does not account for this. That is why I was merely suggesting a 'format_with_time_zone' option you could pass to the new constructor.
DateTime::Format::Strptime already takes time_zone as a parameter. Why should you have the set the time zone as an extra step every time you want to display it? Most of the work is already there, just thought it'd be a nice feature that seemed in-line with the intent of the mondule and save people time and space in their code. If I'm parsing strings to a specific time_zone why wouldn't I want to format objects for the same time_zone? If I don't want to be time_zone specific I'd make a formatter with a time_zone of undef. As I said in another reply: When I do this: my $Strp = new DateTime::Format::Strptime( pattern => '%T', locale => 'en_AU', time_zone => 'Australia/Melbourne', ); I expect all data in and data out (parsed and formatted) of the object $Strp be in respect to time_zone 'Australia/Melbourne'. I didn't want the current functionality of DateTime::Format::Strptime to change which is why I suggested the 'format_with_time_zone' option. If I'm way off base about this, no biggie I'll just keep using my subclass. Just thought the feature might help more people than just me. On Tue, Dec 15, 2009 at 4:01 PM, Evan Carroll <m...@evancarroll.com> wrote: > On Tue, Dec 15, 2009 at 7:28 AM, Kevin McGrath <kmcgr...@baknet.com> > wrote: > > Here is my situation. I use the Rose Framework as my ORM under mod_perl, > > fast_cgi, and server_side scripts. I have the framework set up to use > UTC > > to store all datetimes. I do all work in my controllers in UTC time. > The > > majority of the time I need a datetime to be converted to a specific > > time_zone is when it is being displayed to a user. > > > > Doing the work in parse_datetime does not work for me. In fact I almost > > never call parse_datetime directly and when I do it's to get the datetime > > passed in from a form into UTC. I need/want the time_zone conversion to > > also happen within the format_datetime function when necessary. > > > > The idea is that I should be able to have 1 datetime object that has > already > > be created in UTC and easily show that same datetime object to multiple > > users in the pattern and time_zone they prefer. > > It is an interesting idea, but the traditional DateTime::Format > convention for format_datetime does not include timezone math already > done through $dt->set_time_zone( $tz ). If you had a variable output > pattern dependent on the timezone I could see the need, it is very > easily done too using DateTimeX::Format > > my $dt = parse_datetime( ... ); > $dt->set_time_zone( $tz ); > format_datetime($dt); > > -- > Evan Carroll > System Lord of the Internets >