Module:Japanese calendar/doc
![]() | This is a documentation subpage for Module:Japanese calendar. It may contain usage information, categories and other content that is not part of the original module page. |
This module is used to calculate dates in the Japanese calendar. It defines an "era" class which is designed to be called from other Lua modules, and it also contains several functions to export Japanese calendar data directly to Wikipedia pages through #invoke.
Usage
Through #invoke
{{#invoke:Japanese calendar|function_name|year=year|era=article name or kanji}}
The function name specifies how the data should be outputted. The year
and era
parameters determine what era and year the module outputs.
- Functions
Code | Description | Example |
---|---|---|
baseyear |
The first year of the specified era. | {{#invoke:Japanese calendar|baseyear|article=Heisei}} →
|
year |
The year for the specified era, without the era name. | {{#invoke:Japanese calendar|year|year=1989}} → 1
|
kanjiyear |
The same as year , but in kanji. Only affects the first year of an era. |
{{#invoke:Japanese calendar|kanjiyear|year=1989}} → 元
|
article |
The Wikipedia article for the era, unlinked. | {{#invoke:Japanese calendar|article|year=1950}} → Shōwa (1926–1989)
|
label |
The name of the era. Same as article for undisambiguated titles. |
{{#invoke:Japanese calendar|label|year=1950}} → Shōwa
|
link |
A link to the Wikipedia article of the specified era. | {{#invoke:Japanese calendar|link|year=1950}} → Shōwa
|
kanji |
The kanji for the specified era. | {{#invoke:Japanese calendar|kanji|year=1950}} → 昭和
|
label_year |
label followed by year |
{{#invoke:Japanese calendar|label_year|year=1989}} → Heisei 1
|
link_year |
link followed by year |
{{#invoke:Japanese calendar|link_year|year=1989}} → Heisei 1
|
label_kanjiyear |
label followed by kanjiyear |
{{#invoke:Japanese calendar|label_kanjiyear|year=1989}} → Heisei 元
|
link_kanjiyear |
link followed by kanjiyear |
{{#invoke:Japanese calendar|link_kanjiyear|year=1989}} → Heisei 元
|
From another Lua module
First of all, the era class must be loaded, like this:
local era = require( 'Module:Japanese calendar' ).era
Once the class is loaded, you can make a new era object using era:new()
:
local myEra = era:new{ year = year, era = article name or kanji }
Either year
or era
must be specified.
- Properties
Era objects have no methods, but they do have a number of properties. Their values might be nil
if they could not be processed, or false
if they correspond to an invalid era. You can specify properties with the dot syntax:
local article = myEra.article
The properties are as follows:
gregorianYear
: a number representing the year in the Gregorian calendar. Same as the input year.startYear
: a number representing the first year of the specified era.eraYear
: a number representing the year of the specified era, without the era name.eraYearKanji
: a string representing the era year in kanji. Only the first year of an era is converted to kanji, but all years are strings.article
: the Wikipedia article for the era, unlinked.label
: the name of the era. Same asarticle
unless the article title is disambiguated.kanji
: the name of the era in kanji.