root/Date-Japanese-Era/trunk/README

Revision 230 (checked in by miyagawa, 19 years ago)

Initial revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 NAME
2     Date::Japanese::Era - Conversion between Japanese Era / Gregorian
3     calendar
4
5 SYNOPSIS
6       use Date::Japanese::Era;
7
8       # from Gregorian (month + day required)
9       $era = Date::Japanese::Era->new(1970, 1, 1);
10
11       # from Japanese Era
12       $era = Date::Japanese::Era->new('ŸŒÏÂ', 52);
13
14       $name      = $era->name;         # 'ŸŒÏÂ' in EUC-jp (default)
15       $gengou    = $era->gengou;       # same
16
17       $year      = $era->year;         # 52
18       $gregorian = $era->gregorian_year;       # 1977
19
20 DESCRIPTION
21     Date::Japanese::Era handles conversion between Japanese Era and
22     Gregorian calendar.
23
24 METHODS
25     new
26           $era = Date::Japanese::Era->new($year, $month, $day);
27           $era = Date::Japanese::Era->new($era_name, $year);
28
29         Constructs new Date::Japanese::Era instance. When constructed from
30         Gregorian date, month and day is required. You need Date::Calc to
31         construct from Gregorian.
32
33         Name of era can be either of Japanese / ASCII. Input encodings can
34         be specified via codeset(), suppose you have Jcode module installed.
35         Default is EUC-JP.
36
37         Exceptions are thrown when inputs are invalid (e.g: non-existent
38         era-name and year combination, unknwon era-name, etc.).
39
40     codeset
41           $codeset = Date::Japanese::Era->codeset;
42           Date::Japanese::Era->codeset($encoding);
43
44         sets / gets external encoding of Japanese era names. For example
45         with the follwing code, input and output of era names are encoded in
46         UTF-8.
47
48           Date::Japanese::Era->codeset('utf8');
49           $era = Date::Japanese::Era->new($name, $year); # $name is UTF-8
50           print $era->name;                              # also UTF-8
51
52         You need Jcode module installed to make use of this feature.
53
54     name
55           $name = $era->name;
56
57         returns era name in Japanese. Encoding can be specified via
58         codeset() class method. Default is EUC-JP.
59
60     gengou
61         alias for name().
62
63     name_ascii
64           $name_ascii = $era->name_ascii;
65
66         returns era name in US-ASCII.
67
68     year
69           $year = $era->year;
70
71         returns year as Japanese era.
72
73     gregorian_year
74           $year = $era->gregorian_year;
75
76         returns year as Gregorian.
77
78 EXAMPLES
79       # 2001 is H-13
80       my $era = Date::Japanese::Era->new(2001, 8, 31);
81       printf "%s-%s", uc(substr($era->name_ascii, 0, 1)), $era->year;
82
83       # to Gregorian
84       my $era = Date::Japanese::Era->new('Ê¿À®', 13);
85       print $era->gregorian_year;
86
87 CAVEATS
88     *   The day era just changed is handled as newer one.
89
90     *   Currently supported era is up to 'meiji'.
91
92     *   If someday current era (heisei) is changed, Date::Japanese::Era
93         should be upgraded. (Table is declared as global variable, so you
94         can overwrite it if necessary).
95
96 TODO
97     *   Date parameters can be in various format. I should replace
98         Date::Simple or whatever for that.
99
100     *   Support earlier eras.
101
102 AUTHOR
103     Tatsuhiko Miyagawa <miyagawa@bulknews.net>
104
105     This library is free software; you can redistribute it and/or modify it
106     under the same terms as Perl itself.
107
108 SEE ALSO
109     the Date::Calc manpage, the Jcode manpage, the Date::Simple manpage
110
Note: See TracBrowser for help on using the browser.