Template:DayNav/doc

DayNav provides a calendar of days by which users can navigate through our timeline-by-day pages. It does a number of things automatically for our users, but it currently fails to do some other things.

What it does
When placed onto a page in the format of 3rd January, this template will automatically determine that the month is January, then link each day number on its calendar to January. It also provides the surrounding months so that users can easily navigate to other months.

What it doesn't do
It doesn't contextualize the number of days that are actually in a particular month. The layout of the calendar does not vary depending upon the month, so February appears to have the same 31 days as March. However, red links do show, thus giving each month a kind of unique look.

How it works
The main "trick" of the template is to look at the name of the page, truncate the last five letters, substitute the full month name, then append that name to a number, thus providing [day number + month name]. If it's on the page 5th October, for instance, it grabs "tober" from the page name, then realizes that means October. It then puts up a blank calendar with 31 days. With every number on the calendar, it then combines the cardinal form of the number (1st, 2nd, 3rd) with the derived month name, and links to it. Hence, from the single act of determining that the last five letters of the page name are "tober", it can easily link to all 31 days in the month of October.

Four months, however, don't follow this pattern. For September, November and December, the template reads the last 6 letters of the page name to determine which of the "ember" months it's dealing with. Meanwhile, the month of May is treated as the default month, since the brevity of its name is unique.

The underlying styling of the template, such as the shadow-y elments that affect the box, and most of the text styling, are controlled through CSS, and thus will not be directly visible by viewing the source of this page.

Credit
This template is in almost every respect unique to this wiki. However, the actual layout of the 31 numbers on the page was derived from wikipedia:template:January 2005/events.