NAME

DateTime::Format::Unicode - Unicode CLDR Formatter for DateTime

SYNOPSIS

use DateTime::Format::Unicode;
my $fmt = DateTime::Format::Unicode->new(
    locale      => 'ja-Kana-JP',
    # optional, defaults to the locale medium size date formatting
    # See: DateTime::Locale::FromCLDR for more information
    pattern     => 'HH:mm:ss',
    # optional
    time_zone   => 'Asia/Tokyo',
    # will make error become fatal and have this API die instead of setting an exception object
    on_error    => 'fatal',
) || die( DateTime::Format::Unicode->error );

or, maybe, just:

my $fmt = DateTime::Format::Unicode->new;

which, will default to locale en with date medium-size format pattern MMM d, y

VERSION

v0.1.0

DESCRIPTION

This is a Unicode CLDR (Common Locale Data Repository) formatter for DateTime

It differs from the default formatter used in DateTime with its method format_cldr in several aspects:

DateTime::Format::Unicode only formats CLDR datetime patterns, and does not parse them back into a DateTime object. If you want to achieve that, there is already the module DateTime::Format::CLDR that does this. DateTime::Format::CLDR relies on "format_cldr" in DateTime for CLDR formatting by the way.

CONSTRUCTOR

new

This takes some hash or hash reference of options, instantiates a new DateTime::Format::Unicode object, and returns it.

Supported options are as follows. Each option can be later accessed or modified by their associated method.

METHODS

format_datetime

This takes a DateTime object, or if none is provided, it will instantiate one using "now" in DateTime, and formats the pattern that was set and return the resulting formatted string.

Errors

This module does not die upon errors unless requested to. Instead it sets an error object that can be retrieved.

When an error occurred, an error object will be set and the method will return undef in scalar context and an empty list in list context.

The only occasions when this module will die is when there is an internal design error, which would be my fault, or if the value set with on_error is fatal or also if the CODE reference set with on_error would, itself, die.

AUTHOR

Jacques Deguest <jack@deguest.jp>

SEE ALSO

DateTime, DateTime::Format::FromCLDR, Locale::Unicode, Locale::Unicode::Data, DateTime::Locale

COPYRIGHT & LICENSE

Copyright(c) 2024 DEGUEST Pte. Ltd.

All rights reserved This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.