NAME

DateTime::Format::Japanese - A Japanese DateTime Formatter

SYNOPSIS

use DateTime::Format::Japanese;
my $fmt = DateTime::Format::Japanese->new();

# or if you want to set options,
my $fmt = DateTime::Format::Japanese->new(
  number_format         => FORMAT_KANJI,
  year_format           => FORMAT_ERA,
  with_gregorian_marker => 1,
  with_bc_marker        => 1,
  with_ampm_marker      => 1,
  with_day_of_week      => 1
);

my $str = $fmt->format_datetime($dt);
my $dt  = $fmt->parse_datetime("Ê¿À®£±£¶Ç¯£±·î£²£·Æü¸áÁ°£µ»þ£³£°Ê¬");
  

DESCRIPTION

This module implements a DateTime::Format module that can read Japanese date notations and create a DateTime 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)
year_format           - how to format years (default: FORMAT_ERA)
with_day_of_week      - include day of week (default: 0)
with_gregorian_marker - use gregorian marker (default: 0)
with_bc_marker        - use B.C. marker (default: 0)
with_am_marker        - use A.M/P.M 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 Japanese date/time string and convert it to a DateTime 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->parse_datetime($string);
# or
my $fmt = DateTime::Format::Japanese->new();
my $fmt->parse_daettime($string);

FORMATTING METHODS

All of the following methods accept a single parameter, a DateTime object, and return the appropriate string representation.

my $dt  = DateTime->now();
my $fmt = DateTime::Format::Japanese->new(...);
my $str = $fmt->format_datetime($dt);

$fmt->format_datetime($dt)

Create a complete string representation of a DateTime 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 object in Japanese

$fmt->format_month($dt)

Create a string representation of the month of a DateTime object in Japanese

$fmt->format_day($dt)

Create a string representation of the day (day of month) of a DateTime object in Japanese

$fmt->format_day_of_week($dt)

Create a string representation of the day of week of a DateTime object in Japanese

$fmt->format_time($dt)

Create a string representation of the time (hour, minute, second) of a DateTime object in Japanese

$fmt->format_hour($dt)

Create a string representation of the hour of a DateTime object in Japanese

$fmt->format_minute($dt)

Create a string representation of the minute of a DateTime object in Japanese

$fmt->format_second($dt)

Create a string representation of the second of a DateTime 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.

year_format()

Get/Set the year formatting option. Possible values are:

FORMAT_ERA

Formats the year using the Japanese era notation.

FORMAT_GREGORIAN

Formats the year using the Gregorian notation

with_gregorian_marker()

Get/Set the option to include the gregorian calendar marker ("À¾Îñ")

with_bc_marker()

Get/Set the option to include the "B.C." marker instead of a negative year.

with_ampm_marker()

Get/Set the option to include the AM/PM marker. Implies that the hour notation is swictched to 1-12 from 1-23

with_day_of_week

Get/Set the option to include day of week.

CAVEATS

Day Of Week

Day Of Weeks are accepted in the parsing, but is not used for generating DateTime objects. Only the actual date components are passed to the creation of DateTime object.

Kanji Dates With Units

Kanji notations have the following limitations, which were :

Gregorian years may only expressed like this: 'Æó¡»¡»»Í', not 'ÆóÀé»Í'

All other fields may be expressed as either '½½»Í' or '°ì»Í'. However, it will only understand up to the 10s, not anything higher. This is because of the limit in the range of the fields.

AUTHOR

Daisuke Maki <daisuke@cpan.org>

1 POD Error

The following errors were encountered while parsing the POD:

Around line 470:

Non-ASCII character seen before =encoding in '$fmt->parse_datetime("Ê¿À®£±£¶Ç¯£±·î£²£·Æü¸áÁ°£µ»þ£³£°Ê¬");'. Assuming CP1252