> -----Original Message-----
> From: Dave Rolsky [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, March 21, 2006 4:49 PM
> To: Garrett, Philip (MAN-Corporate)
> Cc: datetime@perl.org
> Subject: RE: Formatting dates for locales/time zones
> 
> On Tue, 21 Mar 2006, Garrett, Philip (MAN-Corporate) wrote:
> 
> >> sub locale_date {
> >>     my ($date,$locale,$time_zone) = @_;
> >>     my $fmt = DateTime::Format::Strptime->new(pattern => '%b %Y',
> >>         locale => $locale, time_zone => $time_zone);
> >>     return $fmt->format_datetime($date); }
> >>
> >> $d = DateTime->now;
> >> $str = locale_date($d, 'fr_FR', 'Europe/Paris'); # "Mar 2005"
> >>
> >> $d = DateTime->now(locale => 'fr_FR', time_zone => 'Europe/Paris');

> >> $str = locale_date($d, 'fr_FR', 'Europe/Paris'); # "mars 2006"
> >>
> >> Is there a way to change this code to use the correct locale for
the 
> >> formatting, but without modifying the original date? (And without 
> >> cloning it -- that's cheating ;-) The locale doesn't seem so much a

> >> property of the date, but of the way it's being presented.
> >
> > So is cloning really the only way to do this?
> 
> I'm afraid so. But that's what the clone api is for. I'm not sure why
> you're averse to it, it's actually implemented in a way that should be
> quite fast.

My aversion is more philosophical than practical. I'm working on
internationalizing some software right now, and (of course) one of the
main goals is to decouple presentation from data. I chose DateTime for
my date needs only to later find that the presentation (locale/output
time zone) for this core support module is embedded in its data. It's
the very thing I've been struggling against for months.

I'm actually quite surprised that *you* don't see this as a problem.

Otherwise, I've been very pleased with the module. The combination of
the Olson data, locales from ICU and the included date math stuff really
are unbeatable. Thanks for your hard work.

Philip

Reply via email to