Difference between revisions of "Template:CalFillFebruary"

From Nookipedia, the Animal Crossing wiki
(Revised all code, as well as Bright Nights (respecting the Monday of second week condition). Added dates of Festivale up to 2050 (http://www.animalcrossingcommunity.com/acnl_festivale_guide.asp). The editor attests to the accuracy of this edit.)
m (Forgot 2027 and 2028 existed for Festivale.)
Line 23: Line 23:
 
-->{{#switch: {{#time:l|01 February {{{year|{{LOCALYEAR}}}}}}} | Tuesday | Wednesday | Thursday | Friday | Saturday = <center>'''[[Bright Nights]]''' <small>({{WW|shortest|nolink}})</small></center>}}<!--
 
-->{{#switch: {{#time:l|01 February {{{year|{{LOCALYEAR}}}}}}} | Tuesday | Wednesday | Thursday | Friday | Saturday = <center>'''[[Bright Nights]]''' <small>({{WW|shortest|nolink}})</small></center>}}<!--
 
--><small><ul><li>[[Boomer]]'s birthday</li></ul></small>
 
--><small><ul><li>[[Boomer]]'s birthday</li></ul></small>
|08 = {{#switch: {{{year|{{LOCALYEAR}}}}} | 2016 | 2028 = <center>'''[[Festivale]]''' <small>({{CF|shortest|nolink}}/{{NL|shortest|nolink}})</small></center>}}<!--
+
|08 = {{#switch: {{{year|{{LOCALYEAR}}}}} | 2016 | 2027 = <center>'''[[Festivale]]''' <small>({{CF|shortest|nolink}}/{{NL|shortest|nolink}})</small></center>}}<!--
 
-->{{#ifeq: {{#time:l|01 February {{{year|{{LOCALYEAR}}}}}}} | Saturday | <center>'''[[Fishing Tourney]]''' <small>({{CF|shortest|nolink}}/{{NL|shortest|nolink}})</small></center>}}<!--
 
-->{{#ifeq: {{#time:l|01 February {{{year|{{LOCALYEAR}}}}}}} | Saturday | <center>'''[[Fishing Tourney]]''' <small>({{CF|shortest|nolink}}/{{NL|shortest|nolink}})</small></center>}}<!--
 
-->{{#switch: {{#time:l|01 February {{{year|{{LOCALYEAR}}}}}}} | Monday | Tuesday | Wednesday | Thursday | Friday | Saturday = <center>'''[[Bright Nights]]''' <small>({{WW|shortest|nolink}})</small></center>}}<!--
 
-->{{#switch: {{#time:l|01 February {{{year|{{LOCALYEAR}}}}}}} | Monday | Tuesday | Wednesday | Thursday | Friday | Saturday = <center>'''[[Bright Nights]]''' <small>({{WW|shortest|nolink}})</small></center>}}<!--
Line 78: Line 78:
 
-->{{#ifeq: {{#time:l|01 February {{{year|{{LOCALYEAR}}}}}}} | Tuesday | <center>'''[[Flea Market]]''' <small>({{CF|shortest|nolink}})</small></center> <center>'''[[Fishing Tourney]]''' <small>({{WW|shortest|nolink}})</small></center>}}<!--
 
-->{{#ifeq: {{#time:l|01 February {{{year|{{LOCALYEAR}}}}}}} | Tuesday | <center>'''[[Flea Market]]''' <small>({{CF|shortest|nolink}})</small></center> <center>'''[[Fishing Tourney]]''' <small>({{WW|shortest|nolink}})</small></center>}}<!--
 
--><small><ul><li>[[Rosie]]'s birthday</li></ul></small>
 
--><small><ul><li>[[Rosie]]'s birthday</li></ul></small>
|28 = {{#switch: {{{year|{{LOCALYEAR}}}}} | 2022 | 2033 = <center>'''[[Festivale]]''' <small>({{CF|shortest|nolink}}/{{NL|shortest|nolink}})</small></center>}}<!--
+
|28 = {{#switch: {{{year|{{LOCALYEAR}}}}} | 2022 | 2028 | 2033 = <center>'''[[Festivale]]''' <small>({{CF|shortest|nolink}}/{{NL|shortest|nolink}})</small></center>}}<!--
 
-->{{#ifeq: {{#time:l|01 February {{{year|{{LOCALYEAR}}}}}}} | Monday | <center>'''[[Flea Market]]''' <small>({{CF|shortest|nolink}})</small></center> <center>'''[[Fishing Tourney]]''' <small>({{WW|shortest|nolink}})</small></center>}}<!--
 
-->{{#ifeq: {{#time:l|01 February {{{year|{{LOCALYEAR}}}}}}} | Monday | <center>'''[[Flea Market]]''' <small>({{CF|shortest|nolink}})</small></center> <center>'''[[Fishing Tourney]]''' <small>({{WW|shortest|nolink}})</small></center>}}<!--
 
--><small><ul><li>[[Naomi]]'s birthday</li></ul></small>
 
--><small><ul><li>[[Naomi]]'s birthday</li></ul></small>
Line 92: Line 92:
 
==Coding notes==
 
==Coding notes==
 
*The template determines when a non-date specific event (e.g. fourth Thursday in November) occurs by using the following formula for each possible date that event could occur on: <blockquote><tt><nowiki>{{#ifeq: {{#time:l|01 January {{{year|{{LOCALYEAR}}}}}}} | Tuesday |...}}</nowiki></tt></blockquote> In this example, the template is checking to see if the first day of January was a Tuesday, and if so it will insert information about the event (represented by "..." in this example). If an event lasts for more than one day (e.g. [[Bright Nights]]) a #switch function is used instead, <blockquote><tt><nowiki>{{#switch: {{#time:l|01 January {{{year|{{LOCALYEAR}}}}}}} | Tuesday | Wednesday =...</nowiki></tt></blockquote> however the logic is essentially the same. The usage of <tt>#ifeq</tt> is recommended to facilitate multiple overlapping events.
 
*The template determines when a non-date specific event (e.g. fourth Thursday in November) occurs by using the following formula for each possible date that event could occur on: <blockquote><tt><nowiki>{{#ifeq: {{#time:l|01 January {{{year|{{LOCALYEAR}}}}}}} | Tuesday |...}}</nowiki></tt></blockquote> In this example, the template is checking to see if the first day of January was a Tuesday, and if so it will insert information about the event (represented by "..." in this example). If an event lasts for more than one day (e.g. [[Bright Nights]]) a #switch function is used instead, <blockquote><tt><nowiki>{{#switch: {{#time:l|01 January {{{year|{{LOCALYEAR}}}}}}} | Tuesday | Wednesday =...</nowiki></tt></blockquote> however the logic is essentially the same. The usage of <tt>#ifeq</tt> is recommended to facilitate multiple overlapping events.
**For days with multiple events (i.e., those with multiple <tt>#switch</tt> and <tt>#ifeq</tt> functions), the following hierarchy is recommended. The arrangement of multiple events that occur on the same category (e.g., January's Yay Day and Flea Market, which are both ''events that fall on a non-specific day but on a specific week'') is up to the discretion of the editor; however, it must be consistent in a given template.
+
**For days with multiple events (i.e., those with multiple <tt>#switch</tt> and <tt>#ifeq</tt> functions), the following hierarchy is recommended. The arrangement of multiple events that occur on the same category (e.g., January's Yay Day and Flea Market, which are both ''events that fall on a non-specific day but on a specific week'') is up to the discretion of the editor; however, it must be consistent in a given month.
 
***Events that fall on a specific day every year (e.g., [[Valentine's Day]] and [[Leap Day]]), excluding birthdays
 
***Events that fall on a specific day every year (e.g., [[Valentine's Day]] and [[Leap Day]]), excluding birthdays
 
***Events that fall on a specific day on certain years (e.g., [[Festivale]])
 
***Events that fall on a specific day on certain years (e.g., [[Festivale]])
Line 100: Line 100:
 
**Those who look at the code may be surprised when they see <tt><nowiki><!--\n\t--></nowiki></tt>. The presence of this quirk is to make the code legible for future maintainers, and so that line breaks will not be recorded (e.g., if the <tt>#ifeq</tt> statement fails). The reason why <tt><nowiki>\n\t</nowiki></tt> is not used is because unwanted linebreaks will occur: see [https://www.mediawiki.org/wiki/Topic:Pqwack7wze5mkv2q this page] for more information. For those who will revise the code in the future, they may temporarily replace <tt><nowiki><!--\n\t--></nowiki></tt> with <tt><nowiki>\n\t</nowiki></tt> in a text editor, and do the reverse afterwards.
 
**Those who look at the code may be surprised when they see <tt><nowiki><!--\n\t--></nowiki></tt>. The presence of this quirk is to make the code legible for future maintainers, and so that line breaks will not be recorded (e.g., if the <tt>#ifeq</tt> statement fails). The reason why <tt><nowiki>\n\t</nowiki></tt> is not used is because unwanted linebreaks will occur: see [https://www.mediawiki.org/wiki/Topic:Pqwack7wze5mkv2q this page] for more information. For those who will revise the code in the future, they may temporarily replace <tt><nowiki><!--\n\t--></nowiki></tt> with <tt><nowiki>\n\t</nowiki></tt> in a text editor, and do the reverse afterwards.
 
**With regards to overlapping events, it is assumed that multiple events will occur in the same day. For example, in 1 April 2018, both [[Bunny Day]] and [[April Fool's Day]] occur at the same day in {{NL|short|nolink}}. Another example is 14 February 2026, when both the [[Fishing Tourney]] and [[Valentine's Day]] occur in {{CF|short|nolink}}. Unless otherwise stated, all events that overlap each other will occur at the same day.<br>
 
**With regards to overlapping events, it is assumed that multiple events will occur in the same day. For example, in 1 April 2018, both [[Bunny Day]] and [[April Fool's Day]] occur at the same day in {{NL|short|nolink}}. Another example is 14 February 2026, when both the [[Fishing Tourney]] and [[Valentine's Day]] occur in {{CF|short|nolink}}. Unless otherwise stated, all events that overlap each other will occur at the same day.<br>
*The calculation of certain holidays such as [[Festivale]] and [[Bunny Day]] are particularly difficult. The implementation for these holidays is as follows: determine whether <tt><nowiki>{{{year|{{LOCALYEAR}}}}}</nowiki></tt> matches for some pre-determined date:<blockquote><tt><nowiki>|28 = {{#switch: {{{year|{{LOCALYEAR}}}}} | 2022 | 2033 = ...</nowiki></tt></blockquote>A list, for example, of all dates for Festivale must be known beforehand. This is much easier; however, it means that the template must be updated sometime in the future to show the correct dates for certain holidays in 2050 onward.
+
*The calculation of certain holidays such as [[Festivale]] and [[Bunny Day]] are particularly difficult, for they depend on the lunisolar calendar. The implementation for these holidays is as follows: determine whether <tt><nowiki>{{{year|{{LOCALYEAR}}}}}</nowiki></tt> matches for some pre-determined date:<blockquote><tt><nowiki>|28 = {{#switch: {{{year|{{LOCALYEAR}}}}} | 2022 | 2033 = ...</nowiki></tt></blockquote>A list, for example, of all dates for Festivale must be known beforehand. This is much easier; however, it means that the template must be updated sometime in the future to show the correct dates for certain holidays in 2050 onward.
 
</noinclude>
 
</noinclude>

Revision as of 06:20, January 25, 2019

← January February 2024 March →
Sunday Monday Tuesday Wednesday Thursday Friday Saturday
28
29
30
Groundhog Day (AC/CF/NL)
31
Flea Market (WW)
1
2
Bright Nights (WW)
3
Bright Nights (WW)
4
Bright Nights (WW)
5
Bright Nights (WW)
6
Bright Nights (WW)
7
Fishing Tourney (CF/NL)
Bright Nights (WW)
8
Bright Nights (WW)
9
Festivale (CF/NL)
10
11
Valentine's Day (AC/CF/NL)
12
13
14
15
16
17
18
19
20
21
22
Flea Market (CF)
Fishing Tourney (WW)
23
24
25
26
Leap Day (CF/NL)
27
28
29
1
2


Usage

{{CalFillFebruary|year=YEAR}}

This template is used to automatically generate and populate a template call for Template:Calendar for the month of February for a year YEAR. If no year is provided, the current year will be used.

Coding notes

  • The template determines when a non-date specific event (e.g. fourth Thursday in November) occurs by using the following formula for each possible date that event could occur on:

    {{#ifeq: {{#time:l|01 January {{{year|{{LOCALYEAR}}}}}}} | Tuesday |...}}

    In this example, the template is checking to see if the first day of January was a Tuesday, and if so it will insert information about the event (represented by "..." in this example). If an event lasts for more than one day (e.g. Bright Nights) a #switch function is used instead,

    {{#switch: {{#time:l|01 January {{{year|{{LOCALYEAR}}}}}}} | Tuesday | Wednesday =...

    however the logic is essentially the same. The usage of #ifeq is recommended to facilitate multiple overlapping events.
    • For days with multiple events (i.e., those with multiple #switch and #ifeq functions), the following hierarchy is recommended. The arrangement of multiple events that occur on the same category (e.g., January's Yay Day and Flea Market, which are both events that fall on a non-specific day but on a specific week) is up to the discretion of the editor; however, it must be consistent in a given month.
      • Events that fall on a specific day every year (e.g., Valentine's Day and Leap Day), excluding birthdays
      • Events that fall on a specific day on certain years (e.g., Festivale)
      • Events that fall on a non-specific day but on a specific week (e.g., Fishing Tourney)
      • Events that span multiple days (e.g., Bright Nights)
      • Birthdays
    • Those who look at the code may be surprised when they see <!--\n\t-->. The presence of this quirk is to make the code legible for future maintainers, and so that line breaks will not be recorded (e.g., if the #ifeq statement fails). The reason why \n\t is not used is because unwanted linebreaks will occur: see this page for more information. For those who will revise the code in the future, they may temporarily replace <!--\n\t--> with \n\t in a text editor, and do the reverse afterwards.
    • With regards to overlapping events, it is assumed that multiple events will occur in the same day. For example, in 1 April 2018, both Bunny Day and April Fool's Day occur at the same day in New Leaf. Another example is 14 February 2026, when both the Fishing Tourney and Valentine's Day occur in City Folk. Unless otherwise stated, all events that overlap each other will occur at the same day.
  • The calculation of certain holidays such as Festivale and Bunny Day are particularly difficult, for they depend on the lunisolar calendar. The implementation for these holidays is as follows: determine whether {{{year|{{LOCALYEAR}}}}} matches for some pre-determined date:

    |28 = {{#switch: {{{year|{{LOCALYEAR}}}}} | 2022 | 2033 = ...

    A list, for example, of all dates for Festivale must be known beforehand. This is much easier; however, it means that the template must be updated sometime in the future to show the correct dates for certain holidays in 2050 onward.