DateTime-Format-JP

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

SYNOPSIS
========

        use DateTime::Format::JP;
        my $fmt = DateTime::Format::JP->new(
            hankaku      => 1,
            pattern      => '%c', # default
            traditional  => 0,
            kanji_number => 0,
            zenkaku      => 0,
            time_zone    => 'local',
        );
        my $dt = DateTime->now;
        $dt->set_formatter( $fmt );
        # set the encoding in and out to utf8
        use open ':std' => ':utf8';
        print "$dt\n"; # will print something like 令和3年7月12日午後2:30:20

        my $dt  = $fmt->parse_datetime( "令和3年7月12日午後2時30分" );
        
        my $str = $fmt->format_datetime( $dt );
        print "$str\n";

VERSION
=======

        v0.1.2

DESCRIPTION
===========

This module is used to parse and format Japanese date and time. It is
lightweight and yet versatile.

It implements 2 main methods:
[\"parse\_datetime\"](#parse_datetime){.perl-module} and
[\"format\_datetime\"](#format_datetime){.perl-module} both expect and
return decoded utf8 string.

You can use [Encode](https://metacpan.org/pod/Encode){.perl-module} to
decode and encode from perl internal utf8 representation to real utf8
and vice versa.

METHODS
=======

new
---

The constructor accepts the following parameters:

*hankaku* boolean

:   If true, the digits used will be \"half-size\" (半角), or roman
    numbers like 1, 2, 3, etc.

    The opposite is *zenkaku* (全角) or full-width. This will enable the
    use of double-byte Japanese numbers that still look like roman
    numbers, such as: 1, 2, 3, etc.

    Defaults to true.

*pattern* string

:   The pattern to use to format the date and time. See below the
    available [\"PATTERN TOKENS\"](#pattern-tokens){.perl-module} and
    their meanings.

    Defaults to `%c`

*traditional* boolean

:   If true, then it will use a more traditional date/time
    representation. The effect of this parameter on the formatting is
    documented in [\"PATTERN TOKENS\"](#pattern-tokens){.perl-module}

*kanji\_number* boolean

:   If true, this will have
    [\"format\_datetime\"](#format_datetime){.perl-module} use numbers
    in kanji, such as: 一, 二, 三, 四, etc.

*zenkaku* boolean

:   If true, this will use full-width, ie double-byte Japanese numbers
    that still look like roman numbers, such as: 1, 2, 3, etc.

*time\_zone* string

:   The time zone to use when creating a
    [DateTime](https://metacpan.org/pod/DateTime){.perl-module} object.
    Defaults to `local` if
    [DateTime::TimeZone](https://metacpan.org/pod/DateTime::TimeZone){.perl-module}
    supports it, otherwise it will fallback on `UTC`

error
-----



( run in 1.263 second using v1.01-cache-2.11-cpan-39bf76dae61 )