Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Humanipedia
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module:Year in various calendars/doc
(section)
Module
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Technical details === The module defines three [[class (programming)|classes]] which do the work of setting up the sidebar and displaying the data provided by the calendar functions. These are the <code>calendarBox</code> class, which defines the sidebar; the <code>calendar</code> class, which holds the data for one calendar; and the <code>calendarGroup</code> object, which defines a group of calendar objects with a heading. To load these classes from another module, use the following: <div style="overflow: auto;"><syntaxhighlight lang="lua"> local yearInOtherCalendars = require( 'Module:Year in various calendars' ) local calendarBox = yearInOtherCalendars.calendarBox local calendarGroup = yearInOtherCalendars.calendarGroup local calendar = yearInOtherCalendars.calendar </syntaxhighlight></div> ==== calendarBox class ==== A <code>calendarBox</code> object is initiated with: {{pre| <nowiki>local myCalendarBox = calendarBox:new{ year = </nowiki>''yyyy''<nowiki>, footnotes = </nowiki>''footnotes''<nowiki>, navbar = </nowiki>''page name''<nowiki> }</nowiki> }} * <code>year</code> - sets the Gregorian year to base calendar calculations on. If not specified, the current year is used. * <code>footnotes</code> - sets text to be displayed in a footnotes section at the bottom of the sidebar. * <code>navbar</code> - sets the page name to be used by the [[Template:Navbar|navbar]]. Calendar box objects have the following properties: * <code>calendarBox.year</code> - the Gregorian year number. This is negative for BC years; for example, for the year 100 BC the value of calendarBox.year is <code>-99</code>. (BC years are calculated by "1 - n" rather than "0 - n", as there is no year zero.) * <code>calendarBox.yearText</code> - the Gregorian year text. This is a string value of the format "n" for AD years and "n BC" for BC years. * <code>calendarBox.caption</code> - the text of the box caption (the bold text that appears directly above the box). The default caption is the value of <code>calendarBox.yearText</code>. * <code>calendarBox.footnotes</code> - the text of the box footnotes. * <code>calendarBox.navbar</code> - the page name used by the navbar. Calendar box objects have the following methods: * <code>calendarBox:setCaption( ''caption'' )</code> - sets the box caption (the bold text that appears directly above the box). The default caption is the value of <code>calendarBox.yearText</code>. * <code>calendarBox:addCalendar( ''obj'' )</code> - adds a calendar object or a calendar group object to the calendar box. * <code>calendarBox:addCalendarGroup( ''obj'' )</code> - an alias for <code>myCalendarBox:addCalendar()</code>. * <code>calendarBox:export()</code> - converts the calendar box object to wikicode. This calls <code>calendar:export()</code> and <code>calendarGroup:export()</code> to export calendar objects and calendar group objects. ==== calendar class ==== A <code>calendar</code> object is initiated with: {{pre| <nowiki>local myCalendar = calendar:new()</nowiki> }} Calendar objects have the following properties: * <code>calendar.link</code> - the link name. * <code>calendar.year</code> - the year value. This is always a string value. Calendar objects have the following methods: * <code>calendar:setLink( ''link'', ''display'' )</code> - sets the link name for the calendar object. <code>''link''</code> is the name of Wikipedia's article about the calendar, and <code>''display''</code> is an optional display name for the article link. * <code>calendar:setRawLink( ''wikitext'' )</code> - sets the calendar link as raw wikitext. * <code>calendar:getLink()</code> - gets the link value. * <code>calendar:setYear( ''year'' )</code> - sets the year value for the calendar. <code>''year''</code> can be a number or a string. * <code>calendar:setYearRange( ''startYear'', ''endYear'' )</code> - sets the year value for the calendar as a year range. Both <code>''startYear''</code> and <code>''endYear''</code> must be number values. * <code>calendar:export()</code> - exports the calendar to wikitext. If no link value was found, this returns <code>nil</code>. If a link was found but no year value was found, the calendar is output with a value of <code>''N/A''</code> for the year. ==== calendarGroup class ==== A <code>calendarGroup</code> object is initiated with: {{pre| <nowiki>local myCalendarGroup = calendarGroup:new{ heading = </nowiki>''heading''<nowiki> }</nowiki> }} * <code>heading</code> - the wikitext heading for the calendar group (e.g. <code><nowiki>[[Hindu calendar]]s</nowiki></code>). Calendar group objects have one property: * <code>calendarGroup.heading</code> - the calendar group heading text. Calendar group objects have the following methods: * <code>calendarGroup:addCalendar( ''obj'' )</code> - adds a calendar object to the calendar group. * <code>calendarGroup:export()</code> - converts a calendar group to wikitext. Calls <code>calendar:export()</code> to export individual calendar objects.
Summary:
Please note that all contributions to Humanipedia may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Humanipedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)