Difference between revisions of "Template:CalFillJanuary"

From Nookipedia, the Animal Crossing wiki
(Fixing issue where template would only generate events for the current year)
(Adding coding notes)
Line 36: Line 36:
 
==Usage==
 
==Usage==
 
This template is used to automatically generate and populate a template call for [[Template:Calendar]] for the month of [[January]] for the year specified. If no year is provided, the current year will be used.
 
This template is used to automatically generate and populate a template call for [[Template:Calendar]] for the month of [[January]] for the year specified. 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: <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 February 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.
 +
<br>
 +
*This template also uses an alternate formula where days of the week are assigned a value between 1 and 7, and then this value is added to some constant to determine whether or not an event is to occur on a given day: <blockquote><tt><nowiki>|08 = {{#ifeq: {{#expr: 7+{{#switch: {{#time:l|01 January {{{year|{{LOCALYEAR}}}}}}} | Sunday = 7| Monday = 6| Tuesday = 5| Wednesday = 4| Thursday = 3| Friday = 2| Saturday = 1|}}}}| 8 |...</nowiki></tt></blockquote> This format was abandoned in favor of the initial formula for its brevity.

Revision as of 15:47, December 26, 2016

← December January 2024 February →
Sunday Monday Tuesday Wednesday Thursday Friday Saturday
31
1
New Year's Day
2
3
4
5
6
7
8
9
10
11
12
13
La-Di-Day (WW)
14
15
16
17
18
19
20
Fishing Tourney (WW)
21
Fishing Tourney (CF/NL)
22
23
24
25
26
27
28
Yay Day (WW)
Flea Market (CF)
29
30
31
1
2
3

Usage

This template is used to automatically generate and populate a template call for Template:Calendar for the month of January for the year specified. 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 February 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.


  • This template also uses an alternate formula where days of the week are assigned a value between 1 and 7, and then this value is added to some constant to determine whether or not an event is to occur on a given day:

    |08 = {{#ifeq: {{#expr: 7+{{#switch: {{#time:l|01 January {{{year|{{LOCALYEAR}}}}}}} | Sunday = 7| Monday = 6| Tuesday = 5| Wednesday = 4| Thursday = 3| Friday = 2| Saturday = 1|}}}}| 8 |...

    This format was abandoned in favor of the initial formula for its brevity.