perldoc > DateTime::Locale

📛 NAME

DateTime::Locale - Localization support for DateTime.pm

🚀 Quick Reference

Use CaseCommandDescription
🔹 Load a localeDateTime::Locale->load('en-GB')Get locale object for English (Great Britain)
🔹 Get all locale codesDateTime::Locale->codesReturns list of all available locale codes
🔹 Get all English namesDateTime::Locale->namesReturns list of locale names in English
🔹 Get all native namesDateTime::Locale->native_namesReturns list of locale names in native language
🔹 Register a custom localeDateTime::Locale->register_from_data(\%data)Add a custom locale from a hash of data
🔹 Use locale in DateTimeDateTime->now( locale => 'fr' )Create a DateTime object with a specific locale
🔹 Get native name of locale$loc->native_nameReturns the locale's name in its own language
🔹 Get long datetime format$loc->datetime_format_longReturns the long datetime format string

📌 VERSION

version 1.33

📖 SYNOPSIS

use DateTime::Locale;

my $loc = DateTime::Locale->load('en-GB');

print $loc->native_name, "\n", $loc->datetime_format_long, "\n";

# but mostly just things like ...

my $dt = DateTime->now( locale => 'fr' );
print "Aujourd'hui le mois est " . $dt->month_name, "\n";

📘 DESCRIPTION

DateTime::Locale is primarily a factory for the various locale subclasses. It also provides some functions for getting information on all the available locales.

If you want to know what methods are available for locale objects, then please read the DateTime::Locale::FromData documentation.

đŸ› ī¸ USAGE

This module provides the following class methods:

If the requested locale is not found, a fallback search takes place to find a suitable replacement.

The fallback search order is:

{language}-{script}-{territory}
{language}-{script}
{language}-{territory}-{variant}
{language}-{territory}
{language}

Eg. For the locale code "es-XX-UNKNOWN" the fallback search would be:

es-XX-UNKNOWN   # Fails - no such locale
es-XX           # Fails - no such locale
es              # Found - the es locale is returned as the
                # closest match to the requested id

Eg. For the locale code "es-Latn-XX" the fallback search would be:

es-Latn-XX      # Fails - no such locale
es-Latn         # Fails - no such locale
es-XX           # Fails - no such locale
es              # Found - the es locale is returned as the
                # closest match to the requested id

If no suitable replacement is found, then an exception is thrown.

The loaded locale is cached, so that locale objects may be singletons. Calling DateTime::Locale->register_from_data, DateTime::Locale->add_aliases, or DateTime::Locale->remove_alias clears the cache.

If you just want to make some small changes on top of an existing locale you can get that locale's data by calling $locale->locale_data.

Here is an example of making a custom locale based off of "en-US":

my $locale = DateTime::Locale->load('en-US');
my %data   = $locale->locale_data;
$data{code}               = 'en-US-CUSTOM';
$data{time_format_medium} = 'HH:mm:ss';

DateTime::Locale->register_from_data(%data);

# Prints 18:24:38
say DateTime->now( locale => 'en-US-CUSTOM' )->strftime('%X');

# Prints 6:24:38 PM
say DateTime->now( locale => 'en-US' )->strftime('%X');

The keys that should be present in the hash are the same as the accessor methods provided by DateTime::Locale::FromData, except for the following:

âš™ī¸ LOADING LOCALES IN A PRE-FORKING SYSTEM

If you are running an application that does pre-forking (for example with Starman), then you should try to load all the locales that you'll need in the parent process. Locales are loaded on-demand, so loading them once in each child will waste memory that could otherwise be shared.

🐛 CLDR DATA BUGS

Please be aware that all locale data has been generated from the CLDR (Common Locale Data Repository) project locales data. The data is incomplete, and may contain errors in some locales.

When reporting errors in data, please check the primary data sources first, then where necessary report errors directly to the primary source via the CLDR bug report system. See <http://unicode.org/cldr/filing_bug_reports.html> for details.

Once these errors have been confirmed, please forward the error report and corrections to the DateTime mailing list, datetime AT perl.org.

👑 AUTHOR EMERITUS

Richard Evans wrote the first version of DateTime::Locale, including the tools to extract the CLDR data.

📚 SEE ALSO

datetime AT perl.org mailing list

🆘 SUPPORT

Bugs may be submitted at <https://github.com/houseabsolute/DateTime-Locale/issues>.

There is a mailing list available for users of this distribution, <mailto:datetime AT perl.org>.

đŸ“Ļ SOURCE

The source code repository for DateTime-Locale can be found at <https://github.com/houseabsolute/DateTime-Locale>.

💰 DONATIONS

If you'd like to thank me for the work I've done on this module, please consider making a "donation" to me via PayPal. I spend a lot of free time creating free software, and would appreciate any support you'd care to offer.

Please note that I am not suggesting that you must do this in order for me to continue working on this particular software. I will continue to do so, inasmuch as I have in the past, for as long as it interests me.

Similarly, a donation made in this way will probably not make me work on this software much more, unless I get so many donations that I can consider working on free software full time (let's all have a chuckle at that together).

To donate, log into PayPal and send money to autarch AT urth.org, or use the button at <https://www.urth.org/fs-donation.html>.

👤 AUTHOR

Dave Rolsky <autarch AT urth.org>

đŸ‘Ĩ CONTRIBUTORS

ÂŠī¸ COPYRIGHT AND LICENSE

This software is copyright (c) 2003 - 2021 by Dave Rolsky.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

The full text of the license can be found in the LICENSE file included with this distribution.

DateTime::Locale
📛 NAME 🚀 Quick Reference 📌 VERSION 📖 SYNOPSIS 📘 DESCRIPTION đŸ› ī¸ USAGE âš™ī¸ LOADING LOCALES IN A PRE-FORKING SYSTEM 🐛 CLDR DATA BUGS 👑 AUTHOR EMERITUS 📚 SEE ALSO 🆘 SUPPORT đŸ“Ļ SOURCE 💰 DONATIONS 👤 AUTHOR đŸ‘Ĩ CONTRIBUTORS ÂŠī¸ COPYRIGHT AND LICENSE

Generated by phpman v4.9.25-25-g40dbf62 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-14 10:09 @216.73.217.14
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format

^_top_^