Module:Japanese calendar/doc
This is the documentation page for Module:Japanese calendar
| 26x26px | This module is rated as alpha. It is ready for third-party input, and may be used on a few pages to see if problems arise, but should be watched. Suggestions for new features or changes in their input and output mechanisms are welcome. |
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 period
|
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 asarticleunless the article title is disambiguated.kanji: the name of the era in kanji.