NAME
    DateTime::Format::JP - Japanese DateTime Parser and Formatter

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( "������������������������������������������������" );
    
        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" and "format_datetime"
    both expect and return decoded utf8 string.

    You can use Encode 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: ���, ���, ���, etc.

        Defaults to true.

    *pattern* string
        The pattern to use to format the date and time. See below the
        available "PATTERN TOKENS" 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"

    *kanji_number* boolean
        If true, this will have "format_datetime" 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: ���, ���, ���, etc.

    *time_zone* string
        The time zone to use when creating a DateTime object. Defaults to
        "local" if DateTime::TimeZone supports it, otherwise it will
        fallback on "UTC"

  error
    Returns the latest error set, if any.

    All method in this module return "undef" upon error and set an error
    that can be retrieved with this method.

  format_datetime
    Takes a DateTime object and returns a formatted date and time based on
    the pattern specified, which defaults to %c.

    You can call this method directly, or you can set this formatter object
    in "set_formatter" in DateTime so that ie will be used for
    stringification of the DateTime object.

    See below "PATTERN TOKENS" for the available tokens and their meanings.

  hankaku
    Sets or gets the boolean value for *hankaku*.

  kanji_number
    Sets or gets the boolean value for *kanji_number*.

  parse_datetime
    Takes a string representing a Japanese date, parse it and return a new
    DateTime. If an error occurred, it will return "undef" and you can get
    the error using "error"

  time_zone
    Sets or gets the string representing the time zone to use when creating
    DateTime object. This is used by "parse_datetime"

  traditional
    Sets or gets the boolean value for *traditional*.

  zenkaku
    Sets or gets the boolean value for *zenkaku*.

SUPPORT METHODS
  kanji_to_romaji
    Takes a number in kanji and returns its equivalent value in roman
    (regular) numbers.

  lookup_era
    Takes an Japanese era in kanji and returns an
    "DateTime::Format::JP::Era" object

  lookup_era_by_date
    Takes a DateTime object and returns a "DateTime::Format::JP::Era" object

  make_datetime
    Returns a DateTime based on parameters provided.

  romaji_to_kanji
    Takes a number and returns its equivalent representation in Japanese
    kanji. Thus, for example, 1234 would be returned as "������������������"

    Please note that, since this is intended to be used only for dates, it
    does not format number over 9 thousand. If you think there is such need,
    please contact the author.

  romaji_to_kanji_simple
    Replaces numbers with their Japanese kanji equivalent. It does not use
    numerals.

  romaji_to_zenkaku
    Takes a number and returns its equivalent representation in double-byte
    Japanese numbers. Thus, for example, 1234 would be returned as ������������

  zenkaku_to_romaji
    Takes a string representing a number in full width (������), i.e.
    double-byte and returns a regular equivalent number. Thus, for example,
    ������������ would be returned as 1234

PATTERN TOKENS
    Here are below the available tokens for formatting and the value they
    represent.

    In all respect, they are closely aligned with "strftime" in DateTime
    (see "strftime Patterns" in DateTime), except that the formatter object
    parameters provided upon instantiation alter the values used.

    *   %%

        The % character.

    *   %a

        The weekday name in abbreviated form such as: ���, ���, ���, ���, ���, ���, ���

    *   %A

        The weekday name in its long form such as: ���������, ���������, ���������, ���������, ���������,
        ���������, ���������

    *   %b

        The month name, such as 1���, 2���, etc... 12��� using regular digits.

    *   %B

        The month name using full width (������) digits, such as ������, ������, etc...
        ���������

    *   %h

        The month name using kanjis for numbers, such as ������, ������, etc... ���������

    *   %c

        The datetime format in the Japanese standard most usual form. For
        example for "12th July 2021 14:17:30" this would be:

            ������3���7���12���������2:17:30

        However, if *traditional* is true, then it would rather be:

            ������3���7���12���������2���17���30���

        And if *zenkaku* is true, it will use double-byte numbers instead:

            ���������������������������������������������������������

        And if *kanji_number* is true, it will then be:

            ���������������������������������������������������������

    *   %C

        The century number (year/100) as a 2-digit integer. This is the same
        as "strftime" in DateTime

    *   %d or %e

        The day of month (1-31).

        However, if *zenkaku* is true, then it would rather be with full
        width (������) numbers: ���-������

        And if *kanji_number* is true, it will then be with numbers in
        kanji: ���, ���, etc.. ���, ������, etc..

    *   %D

        Equivalent to "%E%y���%m���%d���"

        This is the Japanese style date including with the leading era name.

        If *zenkaku* is true, "full-width" (double byte) digits will be used
        and if *kanji_number* is true, numbers in kanji will be used
        instead.

        See %F for an equivalent date using the Gregorian years rather than
        the Japanese era.

    *   %E

        This extension is the Japanese era, such as "������" (i.e. "reiwa": the
        current era)

    *   %F

        Equivalent to "%Y���%m���%d���"

        If *zenkaku* is true, "full-width" (double byte) digits will be used
        and if *kanji_number* is true, numbers in kanji will be used
        instead.

        For the year only the conversion from regular digits to Japanese
        kanjis will be done simply by interpolating the digits and not using
        numerals. For example 2021 would become "������������" and not "���������������"

    *   %g

        The year corresponding to the ISO week number, but without the
        century (0-99). This uses regular digits and is the same as
        "strftime" in DateTime

    *   %G

        The ISO 8601 year with century as a decimal number. The 4-digit year
        corresponding to the ISO week number. This has the same format and
        value as %Y, except that if the ISO week number belongs to the
        previous or next year, that year is used instead. Also this returns
        regular digits.

        This uses regular digits and is the same as "strftime" in DateTime

    *   %H

        The hour: 0-23

        If *traditional* is enabled, this would rather be "0-23���"

        However, if *zenkaku* is true, then it would rather use full width
        (������) numbers: "���-���������"

        And if *kanji_number* is true, it will then be something like "������"

    *   %I

        The hour on a 12-hour clock (1-12).

        If *zenkaku* is true, it will use full width numbers and if
        *kanji_number* is true, it will use numbers in kanji instead.

    *   %j

        The day number in the year (1-366). This uses regular digits and is
        the same as "strftime" in DateTime

    *   %m

        The month number (1-12).

        If *zenkaku* is true, it will use full width numbers and if
        *kanji_number* is true, it will use numbers in kanji instead.

    *   %M

        The minute: 0-59

        If *traditional* is enabled, this would rather be "0-59���"

        However, if *zenkaku* is true, then it would rather use full width
        (������) numbers: "���-���������"

        And if *kanji_number* is true, it will then be something like "������"

    *   %n

        Arbitrary whitespace. Same as in "strftime" in DateTime

    *   %N

        Nanoseconds. For other sub-second values use "%[number]N".

        This is a pass-through directly to "strftime" in DateTime

    *   %p or %P

        Either produces the same result.

        Either AM (������) or PM (������) according to the given time value. Noon is
        treated as pm "������" and midnight as am "������".

    *   %r

        Equivalent to "%p%I:%M:%S"

        Note that if *zenkaku* is true, the semi-colon used will be
        double-byte: "���"

        Also if you use this, do not enable *kanji_number*, because the
        result would be weird, something like:

            ��������������������������� # 2:14:30 in this example

    *   %R

        Equivalent to "%H:%M"

        Note that if *zenkaku* is true, the semi-colon used will be
        double-byte: "���"

        Juste like for %r, avoid enabling *kanji_number* if you use this
        token.

    *   %s

        Number of seconds since the Epoch.

        If *zenkaku* is enabled, this will return the value as double-byte
        number.

    *   %S

        The second: "0-60"

        If *traditional* is enabled, this would rather be "0-60���"

        However, if *zenkaku* is true, then it would rather use full width
        (������) numbers: "���-���������"

        And if *kanji_number* is true, it will then be something like "���������"

        (60 may occur for leap seconds. See DateTime::LeapSecond).

    *   %t

        Arbitrary whitespace. Same as in "strftime" in DateTime

    *   %T

        Equivalent to "%H:%M:%S"

        However, if *zenkaku* option is enabled, the numbers will be
        double-byte roman numbers and the separator will also be
        double-byte. For example:

            ������������������������

    *   %U

        The week number with Sunday (���������) the first day of the week (0-53).
        The first���Sunday of January is the first day of week 1.

        If *zenkaku* is enabled, it will return a double-byte number
        instead.

    *   %u

        The weekday number (1-7) with Monday (���������) = 1, ��������� = 2, ��������� = 3,
        ��������� = 4, ��������� = 5, ��������� = 6, ��������� = 7

        If *zenkaku* is enabled, it will return a double-byte number
        instead.

        This is the "DateTime" standard.

    *   %w

        The weekday number (0-6) with Sunday = 0.

        If *zenkaku* is enabled, it will return a double-byte number
        instead.

    *   %W

        The week number with Monday (���������) the first day of the week (0-53).
        The first���Monday of January is the first day of week 1.

        If *zenkaku* is enabled, it will return a double-byte number
        instead.

    *   %x

        The date format in the standard most usual form. For example for
        12th July 2021 this would be:

            ������3���7���12���

        However, if *zenkaku* is true, then it would rather be:

            ���������������������������

        And if *kanji_number* is true, it will then be:

            ���������������������������

    *   %X

        The time format in the standard most usual form. For example for
        "14:17:30" this would be:

            ������2:17:30

        And if *zenkaku* is enabled, it would rather use a double-byte
        numbers and separator:

            ���������������������������

        However, if *traditional* is true, then it would rather be:

            ������2���17���30���

        And if *kanji_number* is true, it will then be:

            ������������������������������

    *   %y

        The year of the era. For example "2021-07-12" would be "������3���7���12���"
        and thus the year value would be 3

        If *zenkaku* is true, it will use full width numbers and if
        *kanji_number* is true, it will use numbers in kanji instead.

    *   %Y

        A 4-digit year, including century (for example, 1991).

        If *zenkaku* is true, "full-width" (double byte) digits will be used
        and if *kanji_number* is true, numbers in kanji will be used
        instead.

        Same as in %F, the conversion from regular digits to Japanese kanjis
        will be done simply by interpolating the digits and not using
        numerals. For example 2021 would become "������������" and not "���������������"

    *   %z

        An RFC-822/ISO 8601 standard time zone specification. (For example
        +1100)

        If *zenkaku* is true, "full-width" (double byte) digits and "+/-"
        signs will be used and if *kanji_number* is true, numbers in kanji
        will be used instead. However, no numeral will be used. Thus a time
        zone offset such as +0900 would be returned as "���������������"

    *   %Z

        The timezone name. (For example EST -- which is ambiguous). This is
        the same as "strftime" in DateTime

HISTORICAL NOTE
    Japanese eras, also known as ������ (gengo) or ������ (nengo) form one of the
    two parts of a Japanese year in any given date.

    It was instituted by and under first Emperor K��toku in 645 AD. So be
    warned that requiring an era-based Japanese date before will not yield
    good results.

    Era name were adopted for various reasons such as a to commemorate an
    auspicious or ward off a malign event, and it is only recently that era
    name changes are tied to a new Emperor.

    More on this here <https://en.wikipedia.org/wiki/Japanese_era_name>

    From 1334 until 1392, there were 2 competing regimes in Japan; the North
    and South. This period was called "Nanboku-ch��" (���������). This module uses
    the official Northern branch.

    Also there has been two times during the period "Asuka" (������������) with no
    era names, from 654/11/24 until 686/8/14 after Emperor K��toku death and
    from 686/10/1 until 701/5/3 after Emperor Tenmu's death just 2 months
    after his enthronement.

    Thus if you want a Japanese date using era during those two periods, you
    will get and empty era.

    More on this here
    <https://ja.wikipedia.org/wiki/%E5%85%83%E5%8F%B7%E4%B8%80%E8%A6%A7_(%E6
    %97%A5%E6%9C%AC)>

AUTHOR
    Jacques Deguest <jack@deguest.jp>

SEE ALSO
    DateTime

COPYRIGHT & LICENSE
    Copyright(c) 2021 DEGUEST Pte. Ltd. DEGUEST Pte. Ltd.

    You can use, copy, modify and redistribute this package and associated
    files under the same terms as Perl itself.