Template talk:Day-1

From Wikipedia, the free encyclopedia

Template:Day-1 is permanently protected from editing, as it is a heavily used or visible template.

Substantial changes should be proposed here, and made by administrators if the proposal is uncontroversial, or has been discussed and is supported by consensus. Use {{editprotected}} to attract the attention of an administrator in such cases.
This template does not have a documentation subpage. If the template page contains categories, interwiki links or usage notes, move these to Template:Day-1/doc. If the template does not require documentation, add |doc=no to this template ({{permprot}}).

Contents

Documentation - Discussion

[edit] Documentation

{{day-1}} adds one to a date or date-specific pagename

[edit] Usage

  • {{Day-1}} — returns yesterday's date
  • {{Day-1|date}} — returns the day before the date passed
  • {{Day-1|datepage|pagetype|year}} — returns the name of the page one day before the datepage passed in

A fourth optional space parameter can be used to specify an alternate separator instead of the default ' ' :

  • {{Day-1|4=space}} — returns yesterday's date
  • {{Day-1|date|4=space}} — returns the day before the date passed
  • {{Day-1|datepage|pagetype|year|space}} — returns the name of the page one day before the datepage passed in

[edit] Example

Code Result
{{Day-1}} June 14
{{Day-1|March 1}} February 29
{{Day-1|Wikipedia:Today's featured article/March 1, 2004|Wikipedia:Today's featured article/|2004}} Wikipedia:Today's featured article/Error: invalid time, 2004

[edit] See also

[edit] Discussion

Contents

[edit] Fourth space parameter

Why is this parameter needed? The only case I've seen for it is to return an underscore instead of a space, within URLs. However, MediaWiki performs this transformation natively, and it is not needed for normal Wiki links. This unnecessarily complicates this huge and ugly template... verdy_p 08:56, 3 May 2006 (UTC)

MediaWiki performs '_' to ' ' transformation natively, but not ' ' to '_' since space is used to indicate the end of the URL in wiki-links. Thus, when a URL needs to include an '_' character it must be specifically stated. Compare the results with ' ' vs '_' below;
16,_2008&action=edit Edit
Edit
In the first example the space is treated as the end of the URL and everything to the right of that as the text to display in the link. In the second example the space is replaced with an underscore and the full correct URL is used. --CBDunkerson 12:36, 3 May 2006 (UTC)

[edit] Ugly and unnecessarily complicate huge template for most cases

This template should be really simplified by separating the 3 usages documented above.

This really increases the workload on the wikiserver, notably for the first case which uses the current datetime, and that should be removed and put into a separate and much simpler template.

The huge part of this template is needed only when the pagetype parameter is used:

  • Make things really simpler when pagetype is not needed.
  • When pagetype is needed, this template will not use the current datetime, because this use will be inserted only in a page which already has an explicit date that does not depend on current date.

verdy_p 08:56, 3 May 2006 (UTC)

As you note, the primary complexity of this template is due to the 'pagetype' usage... barring the introduction of general string manipulation functions or sectional 'PAGENAME' magic words there is no way to simplify that. The {{yesterday}} template already 'splits out' calculation based on the current date as you suggest, but removing that as the 'default' for this template would not reduce the complexity of the code at all. I also can't see how including it "really increases the workload on the wikiserver"... even assuming that the page cache of every page which uses this template is invalidated when the currentdate changes - it's once per day. On a few hundred pages. I haven't really noticed a huge performance hit at midnight each day... so is there any evidence that this is really an issue? --CBDunkerson 12:49, 3 May 2006 (UTC)
I agree that this template should be simplified. --Meno25 15:14, 26 November 2006 (UTC)