DateTime :: Locale contains a very detailed list of date and time formats for different regions and countries. I would like to use it in emails for clients, depending on what country the client is in.
Unfortunately, it’s very difficult to understand from the documentation how to actually use functions for medium or long dates. For example, DateTime :: Locale :: de_DE lists these date formats (excerpts) in a document:
Long
2008-02-05T18:30:30 = 5. Februar 2008
1995-12-22T09:05:02 = 22. Dezember 1995
-0010-09-15T04:44:23 = 15. September -10
Medium
2008-02-05T18:30:30 = 05.02.2008
1995-12-22T09:05:02 = 22.12.1995
-0010-09-15T04:44:23 = 15.09.-010
It's great. According to DateTime :: Locale :: Base, there are methods in the locale object to get these formats: $locale->date_format_long()and $locale->date_format_medium().
googling Sinan Ünür, ():
for my $locale ( qw(ar da de en_GB es fr ru tr) ) {
$dt->set_locale( $locale );
print_date( $dt );
}
sub print_date {
my ($dt) = @_;
my $locale = $dt->locale;
printf(
"In %s: %s\n", $locale->name,
$dt->format_cldr($locale->date_format_full)
);
}
, , , cldr-. . , , . , :
for (qw( ar da de en_GB es fr ru tr )) {
my $dt2 = DateTime->now( locale => $_ );
printf "%s: %s\n", $_, $dt2->format_cldr($dt2->locale->date_format_long);
}
, , , - :
package DateTime;
sub stringify_long {
return $_[0]->format_cldr($_[0]->locale->date_format_long);
}
package Main;
use strict; use warnings;
use DateTime;
my $dt = DateTime->now( locale => 'de_DE' );
print $dt->stringify_long;
. , : DateTime , ?