Template talk:Day+1
From Wikipedia, the free encyclopedia
Contents |
---|
[edit] Documentation
{{day+1}}
adds one to a date or date-specific pagename
[edit] Usage
{{Day+1}}
- returns tomorrow's date
{{Day+1|date}}
- returns the day after the 'date' passed
{{Day+1|datepage|pagetype|year|spacingchar}}
- returns the name of the page one day after the 'datepage' passed in
[edit] Example
Code | Result |
{{Day+1}} |
June 15 |
{{Day+1|February 28}} |
February 29 |
{{Day+1|Wikipedia:Today's featured article/February 28, 2004|Wikipedia:Today's featured article/|2004}} |
Wikipedia:Today's featured article/Error: invalid time, 2004 |
{{day+1|{{day+1}}}} |
June 16 |
{{day+1|Wikipedia:Today's featured article/{{FULLDATE}}|Wikipedia:Today's featured article/|{{CURRENTYEAR}}}} |
Wikipedia:Today's featured article/Error: invalid time, 2008 |
''[http://en.wikipedia.org/w/wiki.phtml?title=Wikipedia:POTD_row/{{day+1|4=_}},_{{CURRENTYEAR}}&action=edit Edit]'' |
Edit |
[edit] See also
[edit] Discussion
Contents |
[edit] Rework
Isn't the code of this template ridiculously strainful on servers? As far as I can tell it is directly {{switch}}ing every possible date for the one after it. This all could be achieved much more neatly with {{calcadd}} and only 12 or so switches. -- Alfakim -- talk 02:35, 28 March 2006 (UTC)
- Because I'd never heard of 'calcadd' when I made it. :] I'll look into it. Though, since 'calcadd' itself contains ~128 switch options and adds another level of template nesting, I'm not sure that it'd really change the level of server resources required. --CBDunkerson 09:18, 28 March 2006 (UTC)
- Ok, I've pondered a bit and come up with one significant obstacle to using 'calcadd' or a variation thereof. The primary purpose that this template was designed for was to 'cycle through' pages organized in date order. See the links at the bottom left of Wikipedia:Tip of the day/April 20, 2006 and thereafter. The way it is currently set up it can receive {{PAGENAME}} as a parameter and produce a new pagename one day later... which is important because it allows the same template call to be included on every page in the series without having to manually type the date for each. In order to use a 'calcadd' type method we would need to isolate the 'day' - which would require that number to be manually set as a parameter on each page calling the template.
- All that being said, for just 'tomorrow' (like {{day+1}} without parameters) it could be done with a 31 day switch, a 12 month switch, and a bit of additional wrapping code around that. If the server resources are a real concern a separate template could be set up for that. Indeed, User:Ed Poor/tomorrow date has everything except leapday, updating the year on December 31, and the ability to insert '_' instead of spaces... all of which are easily added. --CBDunkerson 20:01, 28 March 2006 (UTC)
-
- You misunderstood in your first paragraph there. I'm suggesting a recode of THIS template. It would work like this, in semi-noncoder terms:
{{switch | {{CURRENTMONTH}} {{Calcadd| 1 + {{CURRENTDAY}} }} | case: January 32=February 1 | case: February 29=March 1 | case: March 32=April 1 | case: April 31=May 1 | case: May 32=June 1 | case: June 31=July 1 | case: July 32=August 1 | case: August 32=September 1 | case: September 31=October 1 | case: October 32=November 1 | case: November 31=December 1 | case: December 32=January 1 | default={{CURRENTMONTH}} {{Calcadd| 1 + {{CURRENTDAY}} }} }}
-
- I could probably work in something to consider leap years, and also to return pagenames, but the above will certainly work, and involves rather a small amount of simple code.
- As for {{calcadd}}, it nests one switch in another, i.e. it involves only 1 level of metatemplating. The fact that each switch has about 32 options doesn't matter very much, because
switch
options are ignored by the server (because they always point to nonexistent parameters). The currentday+1
template, however, involves about the same amount of nesting (a tad more I think), but, crucially, countless non-nested templates (i.e. very many occurences ofswitch
(update: I meant,qif
occurences), and it was this that I was worried about for the server.-- Alfakim -- talk 13:07, 29 March 2006 (UTC)
-
-
- edit conflict - No, I understood, but as I said above, that does not (cannot) cover the same capabilities as this template. The problem is that you have to split out {{CURRENTDAY}} in order to remove the redundancy of adding the days for each month (rather than just once). Even if you add a parameter (i.e. {{{day|{{CUURENTDAY}}}}}) to allow this to add one to any day rather than just the current day it would then require the user to input that day number on every page calling the template. You can't just pass in {{PAGENAME}} because you need to separate out the date.
- The above works essentially the same as User:Ed Poor/tomorrow date except that it uses a specialized 'add one to day of month' switch rather than the more generalized calcadd. This is precisely what I meant by "a 31 day switch, a 12 month switch, and a bit of additional wrapping code". Either method would make sense for just calculating 'tomorrow', which is why I was suggesting a separate template for that. It's more efficient for users who don't want anything except the day after today.
- I'm not sure what you are getting at about "very many occurences of
switch
". The current 'day+1' only uses ONE 'switch' call except on February 28 and December 31 (when it uses two)... it thus actually has fewer 'switch' statements then what you are proposing. It does have a lot of 'qif' statements, but those are all for purposes of making the 'year' optional. Pages like Wikipedia:Selected anniversaries/January 1 increment by date without a year while Wikipedia:Tip of the day/April 21, 2006 include a year. I suppose this could be split into with/without year copies to remove all the 'qif' statements if there is concern about the time spent evaluating them. --CBDunkerson 13:39, 29 March 2006 (UTC)- I wouldn't need to add a {{{day}}} parameter. I could recode this template to work precisely as it does now. And I meant qif in the above, not switch, sorry. Should I put up a mock recoded version at {{day+1/2}}?-- Alfakim -- talk 17:25, 29 March 2006 (UTC)
- Based on discussion with Ed Poor I just moved the contents of {{tomorrow}}. Why don't you put your version in there? I've already changed the two calls to that template to use the new {{tomorrow cell}} location so you can just replace the redirect. Based on your description above I think what you are going to come up with is the equivalent of User:Ed Poor/tomorrow date, but please go ahead. I think it will be useful in any case. --CBDunkerson 19:43, 29 March 2006 (UTC)
- I wouldn't need to add a {{{day}}} parameter. I could recode this template to work precisely as it does now. And I meant qif in the above, not switch, sorry. Should I put up a mock recoded version at {{day+1/2}}?-- Alfakim -- talk 17:25, 29 March 2006 (UTC)
-
[edit] Year
When using {{CURRENTYEAR}} after this template, on December 31 the day and month will coreect (January 1) but the year will be the current year (a year early). Instead of {{CURRENTYEAR}}, use:
{{#ifeq: {{Day+1}} | January 1 | {{#expr: {{CURRENTYEAR}} + 1}} | {{CURRENTYEAR}}}}
One December 31 it gives the next year; all other days it gives the current year.
- Or you could just use {{day+1|3={{CURRENTYEAR}}}}. --CBD 17:10, 30 July 2006 (UTC)
Good advice. --Meno25 15:13, 26 November 2006 (UTC)