<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">NAME
    DateTime::Format::JP - Japanese DateTime Parser and Formatter

SYNOPSIS
        use DateTime::Format::JP;
        my $fmt = DateTime::Format::JP-&gt;new(
            hankaku      =&gt; 1,
            pattern      =&gt; '%c', # default
            traditional  =&gt; 0,
            kanji_number =&gt; 0,
            zenkaku      =&gt; 0,
            time_zone    =&gt; 'local',
        );
        my $dt = DateTime-&gt;now;
        $dt-&gt;set_formatter( $fmt );
        # set the encoding in and out to utf8
        use open ':std' =&gt; ':utf8';
        print "$dt\n"; # will print something like д»¤е’Њ3е№ґ7жњ€12ж—ҐеЌ€еѕЊ2:30:20

        my $dt  = $fmt-&gt;parse_datetime( "д»¤е’Њпј“е№ґпј—жњ€пј‘пј’ж—ҐеЌ€еѕЊпј’ж™‚пј“пјђе€†" );
    
        my $str = $fmt-&gt;format_datetime( $dt );
        print "$str\n";

VERSION
        v0.1.0

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 expects and return decoded utf8 string.

    You can use Encode to decode and encode from perl internal utf8
    representation to real utf8.

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"

  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 &lt;DateTime/set_formatter&gt; 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_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:

            д»¤е’Њ3е№ґдёѓжњ€еЌЃдєЊж—ҐеЌ€еѕЊдєЊж™‚еЌЃдёѓе€†дё‰еЌЃз§’

    *   %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:

            д»¤е’Њ3е№ґдёѓжњ€еЌЃдєЊж—Ґ

    *   %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 &lt;https://en.wikipedia.org/wiki/Japanese_era_name&gt;

    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
    &lt;https://ja.wikipedia.org/wiki/%E5%85%83%E5%8F%B7%E4%B8%80%E8%A6%A7_(%E6
    %97%A5%E6%9C%AC)&gt;

AUTHOR
    Jacques Deguest &lt;jack@deguest.jp&gt;

SEE ALSO
    perl

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

</pre></body></html>