DateTime-Format-JP
view release on metacpan or search on metacpan
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\"](#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: ï¼, ï¼, ï¼, 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: ï¼, ï¼, ï¼, 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 )