DateTime-Locale-FromCLDR
view release on metacpan or search on metacpan
# NAME
DateTime::Locale::FromCLDR - DateTime Localised Data from Unicode CLDR
# SYNOPSIS
use DateTime::Locale::FromCLDR;
my $locale = DateTime::Locale::FromCLDR->new( 'ja-Kana-JP' ) ||
die( DateTime::Locale::FromCLDR->error );
my $locale = DateTime::Locale::FromCLDR->new( 'ja-Kana-JP', calendar => 'japanese' ) ||
die( DateTime::Locale::FromCLDR->error );
my $array = $locale->am_pm_abbreviated;
my $array = $locale->available_formats;
$locale->calendar( 'hebrew' );
my $str = $locale->calendar;
# a Locale::Unicode object that stringifies to the initial locale value (ja-Kana-JP)
my $obj = $locale->code;
my $str = $locale->date_at_time_format_full;
my $str = $locale->date_at_time_format_long;
my $str = $locale->date_at_time_format_medium;
my $str = $locale->date_at_time_format_short;
my $str = $locale->date_format_default;
my $str = $locale->date_format_full;
my $str = $locale->date_format_long;
my $str = $locale->date_format_medium;
my $str = $locale->date_format_short;
my $str = $locale->date_formats;
my $str = $locale->datetime_format;
my $str = $locale->datetime_format_default;
my $str = $locale->datetime_format_full;
my $str = $locale->datetime_format_long;
my $str = $locale->datetime_format_medium;
my $str = $locale->datetime_format_short;
my $str = $locale->day_format_abbreviated;
my $str = $locale->day_format_narrow;
my $str = $locale->day_format_short;
my $str = $locale->day_format_wide;
my $str = $locale->day_period_format_abbreviated( $datetime_object );
my $str = $locale->day_period_format_narrow( $datetime_object );
my $str = $locale->day_period_format_wide( $datetime_object );
my $str = $locale->day_period_stand_alone_abbreviated( $datetime_object );
my $str = $locale->day_period_stand_alone_narrow( $datetime_object );
my $str = $locale->day_period_stand_alone_wide( $datetime_object );
my $hashref = $locale->day_periods;
my $str = $locale->day_stand_alone_abbreviated;
my $str = $locale->day_stand_alone_narrow;
my $str = $locale->day_stand_alone_short;
my $str = $locale->day_stand_alone_wide;
my $str = $locale->default_date_format_length;
my $str = $locale->default_time_format_length;
my $str = $locale->era_abbreviated;
my $str = $locale->era_narrow;
my $str = $locale->era_wide;
my $str = $locale->first_day_of_week;
my $str = $locale->format_for( 'yMEd' );
my $str = $locale->gmt_format(0);
my $str = $locale->gmt_format(3600);
my $str = $locale->gmt_format(-3600);
my $str = $locale->gmt_format(-3600, width => 'short');
my $str = $locale->gmt_format(-3600, { width => 'short' });
# Alias for method 'code'
my $obj = $locale->id;
my $array = $locale->interval_format( GyMEd => 'd' );
my $hashref = $locale->interval_formats;
my $greatest_diff = $locale->interval_greatest_diff( $datetime_object_1, $datetime_object_2 );
my $str = $locale->language;
my $str = $locale->language_code;
# Alias for method 'language_code'
my $str = $locale->language_id;
# Locale::Unicode object
my $obj = $locale->locale;
# Equivalent to $locale->locale->as_string
my $str = $locale->locale_as_string;
# As per standard, it falls back to 'wide' format if it is not available
my $str = $locale->metazone_daylight_long( metazone => 'Taipei' );
{
say "Oops: ", $e->message;
}
Or, you could set the global variable `$FATAL_EXCEPTIONS` instead:
use v5.34;
use experimental 'try';
no warnings 'experimental';
$DateTime::Locale::FromCLDR::FATAL_EXCEPTIONS = 1;
try
{
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
# Missing the 'offset' argument
my $str = $locale->format_gmt;
# More code
}
catch( $e )
{
say "Oops: ", $e->message;
}
# VERSION
v0.5.0
# DESCRIPTION
This is a powerful replacement for [DateTime::Locale](https://metacpan.org/pod/DateTime%3A%3ALocale) and [DateTime::Locale::FromData](https://metacpan.org/pod/DateTime%3A%3ALocale%3A%3AFromData) that use static data from over 1,000 pre-generated modu...
It provides the same API as [DateTime::Locale](https://metacpan.org/pod/DateTime%3A%3ALocale), but in a dynamic way. This is important since in the Unicode [LDML specifications](https://unicode.org/reports/tr35/), a `locale` inherits from its parent'...
Once a data is retrieved by a method, it is cached to avoid waste of time.
It also adds a few methods to access the `locale` [at time patterns](https://unicode.org/reports/tr35/tr35-dates.html#dateTimeFormats), such as [date\_at\_time\_format\_full](#date_at_time_format_full), and [native\_variants](#native_variants)
It also provides key support for [day period](https://unicode.org/reports/tr35/tr35-dates.html#Day_Period_Rule_Sets)
It also provides support for interval datetime, and [a method to find the greatest datetime difference element between 2 datetimes](#interval_greatest_diff), as well as a method to get all the [available format patterns for intervals](#interval_forma...
It adds the `short` format for day missing in [DateTime::Locale::FromData](https://metacpan.org/pod/DateTime%3A%3ALocale%3A%3AFromData)
Note that in `CLDR` parlance, there are standard pattern formats. For example `full`, `long`, `medium`, `short` or also `abbreviated`, `short`, `wide`, `narrow` providing various level of conciseness.
# CONSTRUCTOR
## new
# Japanese as spoken in Japan
my $locale = DateTime::Locale::FromCLDR->new( 'ja-JP' ) ||
die( DateTime::Locale::FromCLDR->error );
# Okinawan as spoken in Japan Southern islands
my $locale = DateTime::Locale::FromCLDR->new( 'ryu-Kana-JP-t-de-t0-und-x0-medical' ) ||
die( DateTime::Locale::FromCLDR->error );
use Locale::Unicode;
my $loc = Locale::Unicode->new( 'fr-FR' );
my $locale = DateTime::Locale::FromCLDR->new( $loc ) ||
die( DateTime::Locale::FromCLDR->error );
Specifying a calendar ID other than the default `gregorian`:
my $locale = DateTime::Locale::FromCLDR->new( 'ja-JP', calendar => 'japanese' ) ||
die( DateTime::Locale::FromCLDR->error );
or, using an hash reference:
my $locale = DateTime::Locale::FromCLDR->new( 'ja-JP', { calendar => 'japanese' } ) ||
die( DateTime::Locale::FromCLDR->error );
Instantiate a new [DateTime::Locale::FromCLDR](https://metacpan.org/pod/DateTime%3A%3ALocale%3A%3AFromCLDR) object based on a `locale` provided, and returns it. By default, it uses the calendar `gregorian`, but you can specify a different one with th...
You can provide any `locale`, even complex one as shown above, and only its core part will be retained. So, for example:
my $locale = DateTime::Locale::FromCLDR->new( 'ryu-Kana-JP-t-de-t0-und-x0-medical' ) ||
die( DateTime::Locale::FromCLDR->error );
say $locale; # ryu-Kana-JP
If an error occurs, it sets an [exception object](https://metacpan.org/pod/DateTime%3A%3ALocale%3A%3AFromCLDR%3A%3AException) and returns `undef` in scalar context, or an empty list in list context, or possibly a special `DateTime::Locale::FromCLDR::...
The object is overloaded and stringifies into the core part of the original string provided upon instantiation.
The core part is comprised of the `language` ID, an optional `script` ID, an optional `territory` ID and zero or multiple `variant` IDs. See [Locale::Unicode](https://metacpan.org/pod/Locale%3A%3AUnicode) and the [LDML specifications](https://unicode...
# METHODS
All methods are read-only unless stated otherwise.
## am\_pm\_abbreviated
This is an alias for [am\_pm\_format\_abbreviated](#am_pm_format_abbreviated)
## am\_pm\_format\_abbreviated
my $array = $locale->am_pm_format_abbreviated;
Returns an array reference of the terms used to represent `am` and `pm`
The array reference could be empty if the `locale` does not support specifying `am`/`pm`
For example:
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $ampm = $locale->am_pm_abbreviated
say @$ampm; # AM, PM
my $locale = DateTime::Locale::FromCLDR->new( 'ja' );
my $ampm = $locale->am_pm_abbreviated
say @$ampm; # åå, åå¾
my $locale = DateTime::Locale::FromCLDR->new( 'fr' );
my $ampm = $locale->am_pm_abbreviated
say @$ampm; # Empty
See ["calendar\_term" in Locale::Unicode::Data](https://metacpan.org/pod/Locale%3A%3AUnicode%3A%3AData#calendar_term)
## am\_pm\_format\_narrow
Same as [am\_pm\_format\_abbreviated](#am_pm_format_abbreviated), but returns the narrow format of the AM/PM terms.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
say $locale->am_pm_format_narrow;
## am\_pm\_format\_wide
Same as [am\_pm\_format\_abbreviated](#am_pm_format_abbreviated), but returns the wide format of the AM/PM terms.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
say $locale->am_pm_format_wide;
## am\_pm\_standalone\_abbreviated
Same as [am\_pm\_format\_abbreviated](#am_pm_format_abbreviated), but returns the abbreviated stand-alone format of the AM/PM terms.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
say $locale->am_pm_standalone_abbreviated;
## am\_pm\_standalone\_narrow
Same as [am\_pm\_format\_abbreviated](#am_pm_format_abbreviated), but returns the narrow stand-alone format of the AM/PM terms.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
say $locale->am_pm_standalone_narrow;
## am\_pm\_standalone\_wide
Same as [am\_pm\_format\_abbreviated](#am_pm_format_abbreviated), but returns the wide stand-alone format of the AM/PM terms.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
say $locale->am_pm_standalone_wide;
## available\_formats
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $array = $locale->available_formats;
Returns an array reference of all the format ID available for this `locale`
See ["calendar\_available\_format" in Locale::Unicode::Data](https://metacpan.org/pod/Locale%3A%3AUnicode%3A%3AData#calendar_available_format)
## available\_format\_patterns
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $ref = $locale->available_format_patterns;
Returns an hash reference of all the available format ID to their corresponding pattern for the `locale`
See ["calendar\_available\_format" in Locale::Unicode::Data](https://metacpan.org/pod/Locale%3A%3AUnicode%3A%3AData#calendar_available_format)
## calendar
my $locale = DateTime::Locale::FromCLDR->new( 'ja-Kana-JP', calendar => 'japanese' ) ||
die( DateTime::Locale::FromCLDR->error );
my $str = $locale->calendar; # japanese
$locale->calendar( 'gregorian' );
Sets or gets the [calendar ID](https://metacpan.org/pod/Locale%3A%3AUnicode%3A%3AData#calendar) used to perform queries along with the given `locale`
## code
my $obj = $locale->code;
Returns the [Locale::Unicode](https://metacpan.org/pod/Locale%3A%3AUnicode) object either received or created upon object instantiation.
## date\_at\_time\_format\_full
my $str = $locale->date_at_time_format_full;
Returns the full [date at time pattern](https://unicode.org/reports/tr35/tr35-dates.html#dateTimeFormats)
For example:
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
say $locale->date_at_time_format_full;
# EEEE, MMMM d, y 'at' h:mm:ssâ¯a zzzz
# Tuesday, July 23, 2024 at 1:26:38â¯AM UTC
my $locale = DateTime::Locale::FromCLDR->new( 'fr' );
say $locale->date_at_time_format_full;
# EEEE d MMMM y 'Ã ' HH:mm:ss zzzz
# mardi 23 juillet 2024 Ã 01:27:11 UTC
## date\_at\_time\_format\_long
Same as [date\_at\_time\_format\_full](#date_at_time_format_full), but returns the long format pattern.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
say $locale->date_at_time_format_long;
# MMMM d, y 'at' h:mm:ssâ¯a z
# July 23, 2024 at 1:26:11â¯AM UTC
## date\_at\_time\_format\_medium
Same as [date\_at\_time\_format\_full](#date_at_time_format_full), but returns the medium format pattern.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
say $locale->date_at_time_format_medium;
# MMM d, y 'at' h:mm:ssâ¯a
# Jul 23, 2024 at 1:25:43â¯AM
## date\_at\_time\_format\_short
Same as [date\_at\_time\_format\_full](#date_at_time_format_full), but returns the short format pattern.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
say $locale->date_at_time_format_short;
# M/d/yy 'at' h:mmâ¯a
# 7/23/24 at 1:25â¯AM
## date\_format\_default
This is an alias to [date\_format\_medium](#date_format_medium)
## date\_format\_full
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
say $locale->date_format_full;
# EEEE, MMMM d, y
# Tuesday, July 23, 2024
Returns the [full date pattern](https://unicode.org/reports/tr35/tr35-dates.html#dateFormats)
See also ["calendar\_format\_l10n" in Locale::Unicode::Data](https://metacpan.org/pod/Locale%3A%3AUnicode%3A%3AData#calendar_format_l10n)
## date\_format\_long
Same as [date\_format\_full](#date_format_full), but returns the long format pattern.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
say $locale->date_format_long;
# MMMM d, y
# July 23, 2024
## date\_format\_medium
Same as [date\_format\_full](#date_format_full), but returns the medium format pattern.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
say $locale->date_format_long;
# MMM d, y
# Jul 23, 2024
## date\_format\_short
Same as [date\_format\_full](#date_format_full), but returns the short format pattern.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
say $locale->date_format_short;
# M/d/yy
# 7/23/24
## date\_formats
my $now = DateTime->now( locale => 'en' );
my $ref = $locale->date_formats;
foreach my $type ( sort( keys( %$ref ) ) )
{
say $type, ":";
say $ref->{ $type };
say $now->format_cldr( $ref->{ $type } ), "\n";
}
Would produce:
full:
EEEE, MMMM d, y
Tuesday, July 23, 2024
long:
MMMM d, y
July 23, 2024
medium:
MMM d, y
Jul 23, 2024
short:
M/d/yy
7/23/24
Returns an hash reference with the keys being: `full`, `long`, `medium`, `short` and their value the result of their associated date format methods.
## datetime\_format
This is an alias for [datetime\_format\_medium](#datetime_format_medium)
## datetime\_format\_default
This is also an alias for [datetime\_format\_medium](#datetime_format_medium)
## datetime\_format\_full
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
say $locale->datetime_format_full;
# EEEE, MMMM d, y, h:mm:ssâ¯a zzzz
# Tuesday, July 23, 2024, 1:53:27â¯AM UTC
Returns the [full datetime pattern](https://unicode.org/reports/tr35/tr35-dates.html#dateTimeFormats)
See also ["calendar\_datetime\_format" in Locale::Unicode::Data](https://metacpan.org/pod/Locale%3A%3AUnicode%3A%3AData#calendar_datetime_format)
## datetime\_format\_long
Same as [datetime\_format\_full](#datetime_format_full), but returns the long format pattern.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
say $locale->datetime_format_long;
# MMMM d, y, h:mm:ssâ¯a z
# July 23, 2024, 1:57:02â¯AM UTC
## datetime\_format\_medium
Same as [datetime\_format\_full](#datetime_format_full), but returns the medium format pattern.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
say $locale->datetime_format_medium;
# MMM d, y, h:mm:ssâ¯a
# Jul 23, 2024, 2:03:16â¯AM
## datetime\_format\_short
Same as [datetime\_format\_full](#datetime_format_full), but returns the short format pattern.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
say $locale->datetime_format_short;
# M/d/yy, h:mmâ¯a
# 7/23/24, 2:04â¯AM
## day\_format\_abbreviated
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $days = $locale->day_format_abbreviated;
say @$days;
# Mon, Tue, Wed, Thu, Fri, Sat, Sun
Returns an array reference of week day names abbreviated format with Monday first and Sunday last.
See also ["calendar\_term" in Locale::Unicode::Data](https://metacpan.org/pod/Locale%3A%3AUnicode%3A%3AData#calendar_term)
## day\_format\_narrow
Same as [day\_format\_abbreviated](#day_format_abbreviated), but returns the narrow format days.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $days = $locale->day_format_abbreviated;
say @$days;
# M, T, W, T, F, S, S
## day\_format\_short
Same as [day\_format\_abbreviated](#day_format_abbreviated), but returns the short format days.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $days = $locale->day_format_short;
say @$days;
# Mo, Tu, We, Th, Fr, Sa, Su
## day\_format\_wide
Same as [day\_format\_abbreviated](#day_format_abbreviated), but returns the wide format days.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $days = $locale->day_format_wide;
say @$days;
# Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
## day\_period\_format\_abbreviated
my $dt = DateTime->new( year => 2024, hour => 7 );
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
say $locale->day_period_format_abbreviated( $dt );
# in the morning
my $dt = DateTime->new( year => 2024, hour => 13 );
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
say $locale->day_period_format_abbreviated( $dt );
# in the afternoon
my $dt = DateTime->new( year => 2024, hour => 7 );
my $locale = DateTime::Locale::FromCLDR->new( 'ja-Kana-JP' );
say $locale->day_period_format_abbreviated( $dt );
# æ
# which means "morning" in Japanese
my $dt = DateTime->new( year => 2024, hour => 13 );
my $locale = DateTime::Locale::FromCLDR->new( 'fr' );
say $locale->day_period_format_abbreviated( $dt );
# après-midi
Returns a string representing the localised expression of the period of day the [DateTime](https://metacpan.org/pod/DateTime) object provided is.
If nothing relevant could be found somehow, this will return an empty string. `undef` is returned only if an error occurred.
This is used to provide the relevant value for the token `B` or `b` in the [Unicode LDML format patterns](https://metacpan.org/pod/Locale%3A%3AUnicode%3A%3AData#Format-Patterns)
See also ["calendar\_term" in Locale::Unicode::Data](https://metacpan.org/pod/Locale%3A%3AUnicode%3A%3AData#calendar_term), ["day\_period" in Locale::Unicode::Data](https://metacpan.org/pod/Locale%3A%3AUnicode%3A%3AData#day_period) and [DateTime::For...
## day\_period\_format\_narrow
Same as [day\_period\_format\_abbreviated](#day_period_format_abbreviated), but returns the narrow format of day period.
my $dt = DateTime->new( year => 2024, hour => 7 );
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
say $locale->day_period_format_narrow( $dt );
# in the morning
## day\_period\_format\_wide
Same as [day\_period\_format\_abbreviated](#day_period_format_abbreviated), but returns the wide format of day period.
my $dt = DateTime->new( year => 2024, hour => 7 );
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
say $locale->day_period_format_wide( $dt );
# in the morning
## day\_period\_stand\_alone\_abbreviated
my $dt = DateTime->new( year => 2024, hour => 7 );
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
say $locale->day_period_stand_alone_abbreviated( $dt );
# morning
my $dt = DateTime->new( year => 2024, hour => 13 );
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
say $locale->day_period_stand_alone_abbreviated( $dt );
# afternoon
my $dt = DateTime->new( year => 2024, hour => 7 );
my $locale = DateTime::Locale::FromCLDR->new( 'ja-Kana-JP' );
say $locale->day_period_stand_alone_abbreviated( $dt );
# ""
The previous example would yield nothing, and as per [the LDML specifications](https://unicode.org/reports/tr35/tr35-dates.html#dfst-period), you would need to use the localised AM/PM instead.
my $dt = DateTime->new( year => 2024, hour => 13 );
my $locale = DateTime::Locale::FromCLDR->new( 'fr' );
say $locale->day_period_stand_alone_abbreviated( $dt );
# ap.m.
Returns a string representing the localised expression of the period of day the [DateTime](https://metacpan.org/pod/DateTime) object provided is.
If nothing relevant could be found somehow, this will return an empty string. `undef` is returned only if an error occurred.
This is used to provide a stand-alone word that can be used as a title, or in a different context.
See also ["calendar\_term" in Locale::Unicode::Data](https://metacpan.org/pod/Locale%3A%3AUnicode%3A%3AData#calendar_term), ["day\_period" in Locale::Unicode::Data](https://metacpan.org/pod/Locale%3A%3AUnicode%3A%3AData#day_period) and [DateTime::For...
## day\_period\_stand\_alone\_narrow
Same as [day\_period\_stand\_alone\_abbreviated](#day_period_stand_alone_abbreviated), but returns the narrow stand-alone version of the day period.
my $dt = DateTime->new( year => 2024, hour => 13 );
my $locale = DateTime::Locale::FromCLDR->new( 'fr' );
say $locale->day_period_stand_alone_narrow( $dt );
# ap.m.
## day\_period\_stand\_alone\_wide
Same as [day\_period\_stand\_alone\_abbreviated](#day_period_stand_alone_abbreviated), but returns the wide stand-alone version of the day period.
my $dt = DateTime->new( year => 2024, hour => 13 );
my $locale = DateTime::Locale::FromCLDR->new( 'fr' );
say $locale->day_period_stand_alone_wide( $dt );
# après-midi
## day\_periods
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $hash = $locale->day_periods;
# Would return an hash reference like:
{
midnight => ["00:00", "00:00"],
morning1 => ["06:00", "12:00"],
noon => ["12:00", "12:00"],
afternoon1 => ["12:00", "18:00"],
evening1 => ["18:00", "21:00"],
night1 => ["21:00", "06:00"],
}
Returns an hash reference of day period token and values of 2-elements array (start time and end time in hours and minutes)
## day\_stand\_alone\_abbreviated
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $days = $locale->day_stand_alone_abbreviated;
say @$days;
# Mon, Tue, Wed, Thu, Fri, Sat, Sun
Returns an array reference of week day names in abbreviated format with Monday first and Sunday last.
This is often identical to the `format` type.
See the [LDML specifications](https://unicode.org/reports/tr35/tr35-dates.html#months_days_quarters_eras) for more information on the difference between the `format` and `stand-alone` types.
## day\_stand\_alone\_narrow
Same as [day\_stand\_alone\_abbreviated](#day_stand_alone_abbreviated), but returns the narrow format days.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $days = $locale->day_stand_alone_narrow;
say @$days;
# M, T, W, T, F, S, S
## day\_stand\_alone\_short
Same as [day\_stand\_alone\_abbreviated](#day_stand_alone_abbreviated), but returns the short format days.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $days = $locale->day_stand_alone_short;
say @$days;
# Mo, Tu, We, Th, Fr, Sa, Su
## day\_stand\_alone\_wide
Same as [day\_stand\_alone\_abbreviated](#day_stand_alone_abbreviated), but returns the wide format days.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $days = $locale->day_stand_alone_wide;
say @$days;
# Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
## default\_date\_format\_length
This returns the string `medium`
## default\_time\_format\_length
This returns the string `medium`
## era\_abbreviated
my $array = $locale->era_abbreviated;
say @$array;
# BC, AD
Returns an array reference of era names in abbreviated format.
See also ["calendar\_eras\_l10n" in Locale::Unicode::Data](https://metacpan.org/pod/Locale%3A%3AUnicode%3A%3AData#calendar_eras_l10n)
## era\_narrow
Same as [era\_abbreviated](#era_abbreviated), but returns the narrow format eras.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $array = $locale->era_narrow;
say @$array;
# B, A
## era\_wide
Same as [era\_abbreviated](#era_abbreviated), but returns the wide format eras.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $array = $locale->era_wide;
say @$array;
# Before Christ, Anno Domini
## error
Used as a mutator, this sets an [exception object](https://metacpan.org/pod/DateTime%3A%3ALocale%3A%3AFromCLDR%3A%3AException) and returns an `DateTime::Locale::FromCLDR::NullObject` in object context (such as when chaining), or `undef` in scalar con...
The `DateTime::Locale::FromCLDR::NullObject` class prevents the perl error of `Can't call method "%s" on an undefined value` (see [perldiag](https://metacpan.org/pod/perldiag)). Upon the last method chained, `undef` is returned in scalar context or a...
## fatal
$cldr->fatal(1); # Enable fatal exceptions
$cldr->fatal(0); # Disable fatal exceptions
my $bool = $cldr->fatal;
Sets or get the boolean value, whether to die upon exception, or not. If set to true, then instead of setting an [exception object](https://metacpan.org/pod/DateTime%3A%3ALocale%3A%3AFromCLDR%3A%3AException), this module will die with an [exception o...
use v.5.34; # to be able to use try-catch blocks in perl
use experimental 'try';
no warnings 'experimental';
try
{
my $cldr = DateTime::Locale::FromCLDR->new( 'en', fatal => 1 );
# Forgot the 'offset':
my $str = $locale->format_gmt;
}
catch( $e )
{
say "Error occurred: ", $e->message;
# Error occurred: No value for width was provided.
}
## first\_day\_of\_week
my $integer = $locale->first_day_of_week;
Returns an integer ranging from 1 to 7 where 1 means Monday and 7 means Sunday.
This represents what is the first day of the week for this `locale`
Since the information on the first day of the week pertains to a `territory`, if the `locale` you provided does not have such information, this method will find out the [likely subtag](https://metacpan.org/pod/Locale%3A%3AUnicode%3A%3AData#likely_sub...
See the [LDML specifications about likely subtags](https://unicode.org/reports/tr35/tr35.html#Likely_Subtags) for more information.
For example:
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
Since there is no `territory` associated, this will look up the likely subtag to find the target `locale` is `en-Latn-US`, and thus the `territory` for `en` is `US` and first day of the week is `7`
Another example:
my $locale = DateTime::Locale::FromCLDR->new( 'fr-Latn' );
This will ultimately get the territory `FR` and first day of the week is `1`
# Okinawan as spoken in the Japanese Southern islands
my $locale = DateTime::Locale::FromCLDR->new( 'ryu' );
This will become `ryu-Kana-JP` and thus the `territory` would be `JP` and first day of the week is `7`
This information is cached in the current object, like for all the other methods in this API.
## format\_for
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $pattern = $locale->format_for( 'Bhm' );
Provided with the format ID of an [available format](#available_formats) and this will return the localised `CLDR` pattern.
Keep in mind that the `CLDR` formatting method of [DateTime](https://metacpan.org/pod/DateTime#format_cldr) does not recognise all the `CLDR` pattern tokens. Thus, for example, if you chose the standard available pattern `Bhm`, this method would retu...
my $now = DateTime->now( locale => "en", time_zone => "Asia/Tokyo" );
# Assuming $now = 2024-07-23T21:39:39
say $now->format_cldr( 'h:mm B' );
# 9:39 B
But `B` is the day period, which can be looked up with ["day\_period" in Locale::Unicode::Data](https://metacpan.org/pod/Locale%3A%3AUnicode%3A%3AData#day_period), which provides us with the day period token `night1`, which itself can be looked up wi...
You can use [DateTime::Format::Unicode](https://metacpan.org/pod/DateTime%3A%3AFormat%3A%3AUnicode) instead of the default [DateTime](https://metacpan.org/pod/DateTime) `CLDR` formatting if you want to get better support for all [CLDR pattern tokens]...
With Japanese:
my $locale = DateTime::Locale::FromCLDR->new( 'ja' );
my $pattern = $locale->format_for( 'Bhm' );
# BK:mm
my $now = DateTime->now( locale => "ja", time_zone => "Asia/Tokyo" );
say $now->format_cldr( 'BK:mm' );
# B9:54
But, this should have yielded: `å¤9:54` instead.
## format\_gmt
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
# Get the offset in seconds from the UTC
my $offset = $dt->offset;
my $str = $locale->gmt_format( $offset );
# The 'width' is 'long' by default
my $str = $locale->gmt_format( $offset, width => 'short' );
This returns a localised and formatted GMT timezone given an offset in seconds of the datetime from UTC.
For example:
- `GMT`
- `UTC`
- `ÐÑинÑиÑ`
Optionally, you can provide the `width` option that may have the value `long` (default), or `short`
If the offset is `0`, meaning this is the GMT time, then the localised representation of `GMT` is returned using [timezone\_format\_gmt\_zero](#timezone_format_gmt_zero), otherwise it will use the GMT format provided by [timezone\_format\_gmt](#timez...
Also, if the option `width` is provided with a value `short`, then the GMT hours, minutes, seconds formatting will not be zero padded.
For example:
- `GMT+03:30`
Long
- `GMT+3:30`
Short
- `UTC-03.00`
Long
- `UTC-3`
Short
- `ÐÑинÑиÑ+03:30`
Long
See the [LDML specifications](https://unicode.org/reports/tr35/tr35-dates.html#Using_Time_Zone_Names) for more information.
This would return something like:
{
Bh => [qw( B h )],
Bhm => [qw( B h m )],
d => ["d"],
default => ["default"],
Gy => [qw( G y )],
GyM => [qw( G M y )],
GyMd => [qw( d G M y )],
GyMEd => [qw( d G M y )],
GyMMM => [qw( G M y )],
GyMMMd => [qw( d G M y )],
GyMMMEd => [qw( d G M y )],
H => ["H"],
h => [qw( a h )],
hm => [qw( a h m )],
Hm => [qw( H m )],
hmv => [qw( a h m )],
Hmv => [qw( H m )],
Hv => ["H"],
hv => [qw( a h )],
M => ["M"],
Md => [qw( d M )],
MEd => [qw( d M )],
MMM => ["M"],
MMMd => [qw( d M )],
MMMEd => [qw( d M )],
y => ["y"],
yM => [qw( M y )],
yMd => [qw( d M y )],
yMEd => [qw( d M y )],
yMMM => [qw( M y )],
yMMMd => [qw( d M y )],
yMMMEd => [qw( d M y )],
yMMMM => [qw( M y )],
}
Returns an hash reference of all available interval format IDs and their associated [greatest difference token](https://unicode.org/reports/tr35/tr35-dates.html#intervalFormats)
The `default` interval format pattern is something like `{0}âââ{1}`, but this changes depending on the `locale` and is not always available.
`{0}` is the placeholder for the first datetime and `{1}` is the placeholder for the second one.
See ["interval\_formats" in Locale::Unicode::Data](https://metacpan.org/pod/Locale%3A%3AUnicode%3A%3AData#interval_formats)
## interval\_greatest\_diff
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $diff = $locale->interval_greatest_diff( $dt1, $dt2 );
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $diff = $locale->interval_greatest_diff( $dt1, $dt2, day_period_first => 1 );
# or, using an hash reference instead:
# my $diff = $locale->interval_greatest_diff( $dt1, $dt2, { day_period_first => 1 } );
Provided with 2 [DateTime objects](https://metacpan.org/pod/DateTime), and this will compute the [greatest difference](https://unicode.org/reports/tr35/tr35-dates.html#intervalFormats).
Quoting from the [LDML specifications](https://unicode.org/reports/tr35/tr35-dates.html#intervalFormats):
"The data supplied in CLDR requires the software to determine the calendar field with the greatest difference before using the format pattern. For example, the greatest difference in "Jan 10-12, 2008" is the day field, while the greatest difference i...
If both `DateTime` objects are identical, this will return an empty string.
You can alter the inner working of the algorithm by providing the option `day_period_first` with a true value. This will prioritise the day period over the AM/PM (morning vs afternoon). What this means, is that if you have two datetimes, one with an ...
This is important, because of the way almost all, but 4 locales (`bg`, `id`, `uz` and `zu`), have sliced up their day periods.
For the locale `en`, for example, the day periods are:
- `midnight`
00:00 00:00
- `morning1`
06:00 12:00
- `noon`
12:00 12:00
- `afternoon1`
12:00 18:00
- `evening1`
18:00 21:00
- `night1`
21:00 06:00
As you can see, there are no occurrence of a day period that spans both morning and afternoon, and thus, because of those data, this method would always return, by default, `a` instead of `B`
For the table of the `CLDR` components, see ["Format Patterns" in Locale::Unicode::Data](https://metacpan.org/pod/Locale%3A%3AUnicode%3A%3AData#Format-Patterns)
If an error occurred, an [exception object](https://metacpan.org/pod/DateTime%3A%3ALocale%3A%3AFromCLDR) is set and `undef` is returned in scalar context, and an empty list in list context.
## is\_dst
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $dt = DateTime->new( year => 2024, month => 7, day => 1, time_zone => 'Asia/Tokyo' );
my $bool = $locale->is_dst( $dt );
# 0
my $dt = DateTime->new( year => 2024, month => 7, day => 1, time_zone => 'America/Los_Angeles' );
my $bool = $locale->is_dst( $dt );
# 1
Returns true if the given `timezone` is using daylight saving time, and false otherwise.
The result is cached to ensure repeating calls for the same `timezone` are returned even faster.
If an error occurred, this will set an [exception object](https://metacpan.org/pod/DateTime%3A%3ALocale%3A%3AFromCLDR%3A%3AException), and returns `undef` in scalar context, or an empty list in list context.
How does it work? Very simply, this generates a [DateTime](https://metacpan.org/pod/DateTime) object based on the current year and given `timezone` both for January 1st and July 1st, and get the `timezone` offset for each. If they do not match, the `...
## is\_ltr
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
If an error occurred, an [exception object](https://metacpan.org/pod/DateTime%3A%3AFormat%3A%3AFromCLDR%3A%3AException) is set, and `undef` is returned in scalar context, or an empty list in list context.
## metazone\_generic\_short
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $str = $locale->metazone_generic_short( metazone => 'Atlantic' );
# AT
my $locale = DateTime::Locale::FromCLDR->new( 'fr' );
my $str = $locale->metazone_generic_short( metazone => 'Atlantic' );
# HA
This returns the localised metazone name for the `generic` time and `short` format for the given `metazone` ID.
If nothing can be found, an empty string is returned.
If an error occurred, an [exception object](https://metacpan.org/pod/DateTime%3A%3AFormat%3A%3AFromCLDR%3A%3AException) is set, and `undef` is returned in scalar context, or an empty list in list context.
## metazone\_standard\_long
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $str = $locale->metazone_standard_long( metazone => 'Atlantic' );
# Atlantic Standard Time
my $locale = DateTime::Locale::FromCLDR->new( 'fr' );
my $str = $locale->metazone_standard_long( metazone => 'Atlantic' );
# heure normale de lâAtlantique
This returns the localised metazone name for the `standard` time and `long` format for the given `metazone` ID.
If nothing can be found, an empty string is returned.
If an error occurred, an [exception object](https://metacpan.org/pod/DateTime%3A%3AFormat%3A%3AFromCLDR%3A%3AException) is set, and `undef` is returned in scalar context, or an empty list in list context.
## metazone\_standard\_short
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $str = $locale->metazone_standard_short( metazone => 'Atlantic' );
# AST
my $locale = DateTime::Locale::FromCLDR->new( 'fr' );
my $str = $locale->metazone_standard_short( metazone => 'Atlantic' );
# HNA
This returns the localised metazone name for the `standard` time and `short` format for the given `metazone` ID.
If nothing can be found, an empty string is returned.
If an error occurred, an [exception object](https://metacpan.org/pod/DateTime%3A%3AFormat%3A%3AFromCLDR%3A%3AException) is set, and `undef` is returned in scalar context, or an empty list in list context.
## month\_format\_abbreviated
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $array = $locale->month_format_abbreviated;
say @$array;
# Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec
Returns an array reference of month names in abbreviated format from January to December.
See also ["calendar\_term" in Locale::Unicode::Data](https://metacpan.org/pod/Locale%3A%3AUnicode%3A%3AData#calendar_term)
## month\_format\_narrow
Same as [month\_format\_abbreviated](#month_format_abbreviated), but returns the months in narrow format.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $array = $locale->month_format_narrow;
say @$array;
# J, F, M, A, M, J, J, A, S, O, N, D
## month\_format\_wide
Same as [month\_format\_abbreviated](#month_format_abbreviated), but returns the months in wide format.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $array = $locale->month_format_wide;
say @$array;
# January, February, March, April, May, June, July, August, September, October, November, December
## month\_stand\_alone\_abbreviated
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $array = $locale->month_stand_alone_abbreviated;
say @$array;
# Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec
Returns an array reference of month names in abbreviated stand-alone format from January to December.
See also ["calendar\_term" in Locale::Unicode::Data](https://metacpan.org/pod/Locale%3A%3AUnicode%3A%3AData#calendar_term)
Note that there is often little difference between the `format` and `stand-alone` format types.
See the [LDML specifications](https://unicode.org/reports/tr35/tr35-dates.html#months_days_quarters_eras) for more information on the difference between the `format` and `stand-alone` types.
## month\_stand\_alone\_narrow
Same as [month\_stand\_alone\_abbreviated](#month_stand_alone_abbreviated), but returns the months in narrow format.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $array = $locale->month_stand_alone_narrow;
say @$array;
# J, F, M, A, M, J, J, A, S, O, N, D
## month\_stand\_alone\_wide
Same as [month\_format\_abbreviated](#month_format_abbreviated), but returns the months in wide format.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $array = $locale->month_stand_alone_wide;
say @$array;
# January, February, March, April, May, June, July, August, September, October, November, December
## name
my $locale = DateTime::Locale::FromCLDR->new( 'fr' );
say $locale->name; # French
my $locale = DateTime::Locale::FromCLDR->new( 'fr-CH' );
say $locale->name; # Swiss French
The `locale`'s name in English.
See also [native\_name](#native_name)
## native\_language
my $locale = DateTime::Locale::FromCLDR->new( 'fr-CH' );
say $locale->native_language; # français
Returns the `locale`'s `language` name as written in the `locale` own language.
If nothing can be found, it will return an empty string.
## native\_name
my $locale = DateTime::Locale::FromCLDR->new( 'fr-CH' );
say $locale->native_name; # français suisse
Returns the `locale`'s name as written in the `locale` own language.
If nothing can be found, it will return an empty string.
## native\_script
my $locale = DateTime::Locale::FromCLDR->new( 'fr-Latn-CH' );
say $locale->native_script; # latin
my $locale = DateTime::Locale::FromCLDR->new( 'fr' );
say $locale->native_script; # undef
- `plus`
"Symbol used to denote positive value."
For example `+`
- `superscript`
For example `Ã`, `(^)`
- `time_separator`
This is intended to replace "any use of the `timeSeparator` pattern character in a date-time format pattern"
For example `:`, `Ù«`, `.`
## number\_system
my $locale = DateTime::Locale::FromCLDR->new( 'ar-EG' );
say $locale->number_system;
# arab
my $locale = DateTime::Locale::FromCLDR->new( 'ja' );
say $locale->number_system;
# latn
Returns a string representing the number system for the `locale`
## number\_system\_digits
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $digits = $locale->number_system_digits( 'latn' );
say $digits; # [0, 1, 2, 3, 4, 5, 6, 7, 8. 9];
# Japanese traditional numbering system
my $digits = $locale->number_system_digits( 'jpan' );
say $digits; # ["ã","ä¸","äº","ä¸","å","äº","å
","ä¸","å
«","ä¹"];
Provided with a valid number system ID, and this will return an array reference of digits for that number system, from 0 to 9.
It sets an [exception object](https://metacpan.org/pod/DateTime%3A%3ALocale%3A%3AFromCLDR%3A%3AException) upon error, and returns `undef` in scalar context, or an empty list in list context.
## prefers\_24\_hour\_time
This checks whether the `locale` prefers the 24H format or the 12H one and returns true (`1`) if it prefers the 24 hours format or false (`0`) otherwise.
How it finds out? It pulls the preferred time format from the CLDR data by calling [time\_format\_preferred](#time_format_preferred), and from there returns true (1) if the value is either `H` or `k`, or else false (0).
This is as specified by the [Unicode LDML](https://www.unicode.org/reports/tr35/tr35-dates.html#availableFormats_appendItems), which states: "the locale's actual preference for 12-hour or 24-hour time cycle is determined from the Time Data as describ...
## quarter\_format\_abbreviated
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $array = $locale->quarter_format_abbreviated;
say @$array;
# Q1, Q2, Q3, Q4
Returns an array reference of quarter names in abbreviated format.
See also ["calendar\_term" in Locale::Unicode::Data](https://metacpan.org/pod/Locale%3A%3AUnicode%3A%3AData#calendar_term)
## quarter\_format\_narrow
Same as [quarter\_format\_abbreviated](#quarter_format_abbreviated), but returns the quarters in narrow format.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $array = $locale->quarter_format_narrow;
say @$array;
# 1, 2, 3, 4
## quarter\_format\_wide
Same as [quarter\_format\_abbreviated](#quarter_format_abbreviated), but returns the quarters in wide format.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $array = $locale->quarter_format_wide;
say @$array;
# 1st quarter, 2nd quarter, 3rd quarter, 4th quarter
## quarter\_stand\_alone\_abbreviated
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $array = $locale->quarter_stand_alone_abbreviated;
say @$array;
# Q1, Q2, Q3, Q4
Returns an array reference of quarter names in abbreviated format.
See also ["calendar\_term" in Locale::Unicode::Data](https://metacpan.org/pod/Locale%3A%3AUnicode%3A%3AData#calendar_term)
Note that there is often little difference between the `format` and `stand-alone` format types.
See the [LDML specifications](https://unicode.org/reports/tr35/tr35-dates.html#months_days_quarters_eras) for more information on the difference between the `format` and `stand-alone` types.
## quarter\_stand\_alone\_narrow
Same as [quarter\_stand\_alone\_abbreviated](#quarter_stand_alone_abbreviated), but returns the quarters in narrow format.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $array = $locale->quarter_stand_alone_narrow;
say @$array;
# 1, 2, 3, 4
## quarter\_stand\_alone\_wide
Same as [quarter\_stand\_alone\_abbreviated](#quarter_stand_alone_abbreviated), but returns the quarters in wide format.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $array = $locale->quarter_stand_alone_wide;
say @$array;
# 1st quarter, 2nd quarter, 3rd quarter, 4th quarter
## script
my $locale = DateTime::Locale::FromCLDR->new( 'ja-Kana-JP' );
my $str = $locale->script;
# Katakana
Returns the name of the `locale`'s `script` in English.
If there is no `script` specified in the `locale`, it will return `undef`
If there is a `script` in the `locale`, but, somehow, it cannot be found in the `en` `locale`'s [language tree](https://metacpan.org/pod/Locale%3A%3AUnicode%3A%3AData#make_inheritance_tree), it will return an empty string.
## script\_code
my $locale = DateTime::Locale::FromCLDR->new( 'ja-Kana-JP' );
my $script = $locale->script_code;
# Kana
my $locale = DateTime::Locale::FromCLDR->new( 'ja-JP' );
my $script = $locale->script_code;
# undef
Returns the `locale`'s `script` ID, or `undef` if there is none.
## script\_id
This is an alias for [script\_code](#script_code)
## split\_interval
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $ref = $locale->split_interval(
pattern => $string,
greatest_diff => 'd',
) || die( $locale->error );
This method actually calls ["split\_interval" in Locale::Unicode::Data](https://metacpan.org/pod/Locale%3A%3AUnicode%3A%3AData#split_interval) and passes it all the arguments it received, so please check its documentation.
It returns the array reference it received from ["split\_interval" in Locale::Unicode::Data](https://metacpan.org/pod/Locale%3A%3AUnicode%3A%3AData#split_interval), or upon error, its sets an exception object, and returns `undef` in scalar context or...
## territory
my $locale = DateTime::Locale::FromCLDR->new( 'ja-JP' );
my $script = $locale->territory;
# Japan
my $locale = DateTime::Locale::FromCLDR->new( 'zh-034' );
my $script = $locale->territory;
# Southern Asia
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $script = $locale->territory;
# undef
my $locale = DateTime::Locale::FromCLDR->new( 'en-XX' );
my $script = $locale->territory;
# ''
Returns the name of the `locale`'s `territory` in English.
If there is no `territory` specified in the `locale`, it will return `undef`
If there is a `territory` in the `locale`, but, somehow, it cannot be found in the `en` `locale`'s [language tree](https://metacpan.org/pod/Locale%3A%3AUnicode%3A%3AData#make_inheritance_tree), it will return an empty string.
## territory\_code
my $locale = DateTime::Locale::FromCLDR->new( 'ja-JP' );
my $script = $locale->territory_code;
# JP
my $locale = DateTime::Locale::FromCLDR->new( 'ja-Kana' );
my $script = $locale->territory_code;
# undef
Returns the `locale`'s `territory` ID, or `undef` if there is none.
## territory\_id
This is an alias for [territory\_code](#territory_code)
## territory\_info
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $ref = $locale->territory_info;
which would yield:
{
calendars => undef,
contains => undef,
currency => "USD",
first_day => 7,
gdp => 19490000000000,
languages => [qw(
en es zh-Hant fr de fil it vi ko ru nv yi pdc hnj haw
frc chr esu dak cho lkt ik mus io cic cad jbo osa zh
)],
literacy_percent => 99,
min_days => 1,
parent => "021",
population => 332639000,
status => "regular",
territory => "US",
territory_id => 297,
weekend => undef,
}
my $locale = DateTime::Locale::FromCLDR->new( 'en-GB' );
my $ref = $locale->territory_info;
which would yield:
{
calendars => undef,
contains => undef,
currency => "GBP",
first_day => 1,
gdp => 2925000000000,
languages => [qw(
en fr de es pl pa ur ta gu sco cy bn ar zh-Hant it lt pt
so tr ga gd kw en-Shaw
)],
literacy_percent => 99,
min_days => 4,
parent => 154,
population => 65761100,
status => "regular",
territory => "GB",
territory_id => 121,
weekend => undef,
}
Returns an hash reference of information related to the ISO3166 country code associated with the `locale`. If the `locale` has no country code associated, it will expand it using the Unicode LDML rule with ["likely\_subtag" in Locale::Unicode::Data](...
Keep in mind that the default or fallback data are stored in the special territory code `001` (World). Thus, for example, if the `calendars` field is empty, the default value would be in `001`, and would be `["gregorian"]`
## time\_format\_allowed
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $array = $locale->time_format_allowed;
Returns an array reference of [allowed time patterns](https://unicode.org/reports/tr35/tr35-dates.html#Time_Data) for the `locale`'s associated territory. If the locale has no `territory` associated with, it will check the [likely subtag](https://met...
## time\_format\_default
This is an alias for [time\_format\_medium](#time_format_medium)
## time\_format\_full
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
say $locale->time_format_full;
# h:mm:ssâ¯a zzzz
# 10:44:07â¯PM UTC
Returns the [full date pattern](https://unicode.org/reports/tr35/tr35-dates.html#dateFormats)
See also ["calendar\_format\_l10n" in Locale::Unicode::Data](https://metacpan.org/pod/Locale%3A%3AUnicode%3A%3AData#calendar_format_l10n)
## time\_format\_long
Same as [time\_format\_full](#time_format_full), but returns the long format pattern.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
say $locale->time_format_long;
# h:mm:ssâ¯a z
# 10:44:07â¯PM UTC
## time\_format\_medium
Same as [time\_format\_full](#time_format_full), but returns the medium format pattern.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
say $locale->time_format_medium;
# h:mm:ssâ¯a
# 10:44:07â¯PM
## time\_format\_preferred
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $str = $locale->time_format_preferred;
Returns a string representing the [time preferred pattern](https://unicode.org/reports/tr35/tr35-dates.html#Time_Data) for the `locale`'s associated territory. If the locale has no `territory` associated with, it will check the [likely subtag](https:...
## time\_format\_short
Same as [time\_format\_full](#time_format_full), but returns the short format pattern.
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
say $locale->time_format_short;
# h:mmâ¯a
# 10:44â¯PM
## time\_formats
my $now = DateTime->now( locale => 'en' );
my $ref = $locale->time_formats;
foreach my $type ( sort( keys( %$ref ) ) )
{
say $type, ":";
say $ref->{ $type };
say $now->format_cldr( $ref->{ $type } ), "\n";
}
Would produce:
full:
h:mm:ssâ¯a zzzz
10:44:07â¯PM UTC
long:
h:mm:ssâ¯a z
10:44:07â¯PM UTC
medium:
h:mm:ssâ¯a
10:44:07â¯PM
( run in 1.085 second using v1.01-cache-2.11-cpan-39bf76dae61 )