Rand Stats

Intl::Format::DateTime

zef:guifa

IntlFormatDateTime

Hoy es siempre todavía, toda la vida es ahora. Y ahora, ahora es el momento de cumplir las promesas que nos hicimos. Porque ayer no lo hicimos, porque mañana es tarde. Ahora.
Proverbios y cantares (Antonio Machado)

A module for formatting dates and times in a variety of languages and styles. To use, simple include the module:

use Intl::Format::DateTime
    
my $dt = DateTime.new: now;

format-date $dt;      # Format the date only
format-time $dt;      # Format the time only
format-datetime $dt;  # Format the date and time together

The command options are

If you will be constantly reusing a formatter, you can also obtain a Callable form which will reduce some of the overhead and be more performant:

my &formatter =    local-datetime-formatter :$language, :$length, :$skeleton;
              # or local-date-formatter
              # or local-time-formatter
              
formatter DateTime.now

Current performance is about an order of magnitude slower than DateTime.Str and is about as fast as vanilla Raku can get. The performance gap can be narrowed if alternate nqp versions of formatters are written, but that is not a priority at the moment.

To do

Dependencies

These modules are designed to work together, and as of 2023, are maintained by the same person so should not have issues if fully updated.

Version history

© 2021–2023 Matthew Stephen Stuckwisch. All files licensed under the Artistic License 2.0 except for resources/metaZones.xml which is owned by Unicode, Inc. and licensed under the Unicode License Agreement (found at resources/unicode-license.txt)