DateTime-Format-Japanese
view release on metacpan or search on metacpan
lib/DateTime/Format/Japanese/Traditional.pm view on Meta::CPAN
]
};
require DateTime::Format::Builder;
DateTime::Format::Builder->create_class(
parsers => {
parse_datetime => [
$parse_standard,
$parse_standard_with_quarter
]
}
);
1;
__END__
=head1 NAME
DateTime::Format::Japanese::Traditional - A Japanese DateTime Formatter For Traditional Japanese Calendar
=head1 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("大åä¸å¹´å¼¥ç䏿¥ä¸ä¸ã¤å»");
=head1 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
=head1 METHODS
=head2 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
I<formatting>, and not I<parsing>. Parsing is done in a way such
that it accepts any of the known formats that this module can produce.
=head2 $fmt-E<gt>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.
Note that it will try to auto-detect whatever encoding you're using via
Encode::Guess, so you should be safe to pass any of UTF-8, euc-jp,
shift-jis, and iso-2022-jp encoded strings.
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);
=head1 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);
=head2 $fmt-E<gt>format_datetime($dt)
Create a complete string representation of a DateTime::Calendar::Japanese object in Japanese
=head2 $fmt-E<gt>format_ymd($dt)
Create a string representation of year, month, and date of a DateTime
object in Japanese
=head2 $fmt-E<gt>format_year($dt)
Create a string representation of the year of a DateTime::Calendar::Japanese object in Japanese
=head2 $fmt-E<gt>format_month($dt)
Create a string representation of the month of a DateTime::Calendar::Japanese object in Japanese
=head2 $fmt-E<gt>format_day($dt)
Create a string representation of the day (day of month) of a DateTime::Calendar::Japanese object
in Japanese
=head2 $fmt-E<gt>format_time($dt)
Create a string representation of the time (hour, minute, second) of a DateTime::Calendar::Japanese object in Japanese
=head1 OPTIONS
=head2 input_encoding()
( run in 0.848 second using v1.01-cache-2.11-cpan-39bf76dae61 )