NAME
DateTime::Format::Japanese::Traditional - A Japanese DateTime Formatter For Traditional Japanese Calendar
SYNOPSIS
use DateTime::Format::Japanese::Traditional;
my $fmt = DateTime::Format::Japanese::Traditional->new();
# or if you want to set options,
my $fmt = DateTime::Format::Japanese::Traditional->new(
number_format => FORMAT_KANJI,
month_format => FORMAT_WAREKI_MONTH,
with_traditional_marker => 1
);
my $str = $fmt->format_datetime($dt);
my $dt = $fmt->parse_datetime("Ê¿À®£±£¶Ç¯£±·î£²£·Æü¸áÁ°£µ»þ£³£°Ê¬");
DESCRIPTION
This module implements a DateTime::Format module that can read tradtional Japanese date notations and create a DateTime::Calendar::Japanese object, and vice versa.
XXX WARNING WARNING WARNING XXX
Currently DateTime::Format::Japanese only supports Perl 5.7 and up.
This is because I'm ignorant in the ways of making robust regular
expressions in Perls <= 5.6.x with Jcode. If anybody can contribute to
this, I would much appreciate it
XXX WARNING WARNING WARNING XXX
METHODS
new()
This constructor will create a DateTime::Format::Japanese object. You may optionally pass any of the following parameters:
number_format - how to format numbers (default: FORMAT_KANJI)
month_format - how to format months (default: FORMAT_NUMERIC_MONTH)
with_traditional_marker - use traditional calendar marker (default: 0)
Please note that all of the above parameters only take effect for formatting, and not parsing. Parsing is done in a way such that it accepts any of the known formats that this module can produce.
$fmt->parse_datetime($string)
This function will parse a traditional Japanese date/time string and convert it to a DateTime::Calendar::Japanese object. If the parsing is unsuccessful it will croak.
This method can be called as a class function as well.
my $dt = DateTime::Format::Japanese::Traditional->parse_datetime($string);
# or
my $fmt = DateTime::Format::Japanese::Traditional->new();
my $fmt->parse_daettime($string);
FORMATTING METHODS
All of the following methods accept a single parameter, a DateTime::Calendar::Japanese object, and return the appropriate string representation.
my $dt = DateTime->now();
my $fmt = DateTime::Format::Japanese::Traditional->new(...);
my $str = $fmt->format_datetime($dt);
$fmt->format_datetime($dt)
Create a complete string representation of a DateTime::Calendar::Japanese object in Japanese
$fmt->format_ymd($dt)
Create a string representation of year, month, and date of a DateTime object in Japanese
$fmt->format_year($dt)
Create a string representation of the year of a DateTime::Calendar::Japanese object in Japanese
$fmt->format_month($dt)
Create a string representation of the month of a DateTime::Calendar::Japanese object in Japanese
$fmt->format_day($dt)
Create a string representation of the day (day of month) of a DateTime::Calendar::Japanese object in Japanese
$fmt->format_time($dt)
Create a string representation of the time (hour, minute, second) of a DateTime::Calendar::Japanese object in Japanese
OPTIONS
number_format()
Get/Set the number formatting option. Possible values are:
- FORMAT_ROMAN
-
Formats the numbers in plain ascii roman numerals.
- FORMAT_KANJI
-
Formats numbers in kanji numerals without any unit specifiers.
- FORMAT_ZENKAKU
-
Formats numbers in zenkaku numerals (double-byte equivalent of roman numerals)
- FORMAT_KANJI_WITH_UNIT
-
Formats numbers in kanji numerals, with unit specifiers.
month_format()
Get/Set the month formatting option. Possible values are:
- FORMAT_NUMERIC_MONTH
-
Formats the month using numerals.
- FORMAT_WAREKI_MONTH
-
Formtas the month using traditional Japanese month names.
with_traditional_marker()
Get/Set the option to include a marker that declares the date as a traditional Japanese date.
AUTHOR
Daisuke Maki <daisuke@cpan.org>
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 372:
Non-ASCII character seen before =encoding in '$fmt->parse_datetime("Ê¿À®£±£¶Ç¯£±·î£²£·Æü¸áÁ°£µ»þ£³£°Ê¬");'. Assuming CP1252