DateTime-Format-JP
view release on metacpan or search on metacpan
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*.
( run in 1.465 second using v1.01-cache-2.11-cpan-39bf76dae61 )