Jump to content

Template:Week: Difference between revisions

From Meta, a Wikimedia project coordination wiki
Content deleted Content added
No edit summary
 
(84 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<includeonly>{{{{{subst|}}}#switch: {{{{{subst|}}}#expr:-({{{2}}}=1)*({{{3}}}<4-( ( 1.25* ({{{1}}}-1) -.4 round 0)+({{{1}}}>250)* (2 - ( ({{{1}}}-1) /100 -.495 round 0) +( ({{{1}}}-1) /400 -.499 round 0) ) + 700000001 )mod7 )+({{{2}}}=12)*({{{3}}}>=35-( ( 1.25* {{{1}}} -.4 round 0)+({{{1}}}>250)* (2 - ( {{{1}}} /100 -.495 round 0) +( {{{1}}} /400 -.499 round 0) ) + 700000001 )mod7 )}}|0={{{{{subst|}}}void|
<includeonly>{{{{{subst|}}}eval|({{{{{subst|}}}orddate|subst={{{subst|}}}|{{{{{subst|}}}isoyear|{{{1}}}|{{{2|{{CURRENTMONTH}}}}}|{{{3|{{CURRENTDAY}}}}}}}|{{{{{subst|}}}MJD2M|subst={{{subst|}}}|{{{{{subst|}}}#expr:{{{{{subst|}}}YMD2MJD|subst={{{subst|}}}|{{{1|{{CURRENTYEAR}}}}}|{{{2|{{CURRENTMONTH}}}}}|{{{3|{{CURRENTDAY}}}}}}} - {{{{{subst|}}}DOW|subst={{{subst|}}}|{{{1|{{CURRENTYEAR}}}}}|{{{2|{{CURRENTMONTH}}}}}|{{{3|{{CURRENTDAY}}}}}}} + 4 }}}}|{{{{{subst|}}}MJD2D|subst={{{subst|}}}|{{{{{subst|}}}#expr:{{{{{subst|}}}YMD2MJD|subst={{{subst|}}}|{{{1|{{CURRENTYEAR}}}}}|{{{2|{{CURRENTMONTH}}}}}|{{{3|{{CURRENTDAY}}}}}}} - {{{{{subst|}}}DOW|subst={{{subst|}}}|{{{1|{{CURRENTYEAR}}}}}|{{{2|{{CURRENTMONTH}}}}}|{{{3|{{CURRENTDAY}}}}}}} + 4 }}}}}} + 3 ) / 7 round 0}}</includeonly><noinclude>


case 0
{{#if:{{#ifexpr:


}}{{{{{subst|}}}#expr:({{{{{subst|}}}#switch: {{{2}}}|1=0|2=31|3=59|4=90|5=120|6=151|7=181|8=212|9=243|10=273|11=304|12=334}}
6}}|[expression "
+{{{3}}}
+({{{2}}}>2)* ((({{{1}}}mod4 = 0) and ({{{1}}}mod100 != 0)) or ({{{1}}}mod400 = 0))+6-((( 700000005.2+2.6*({{{2}}}+12*({{{2}}}<3)))round 0)+{{{3}}} + ( 1.25* ({{{1}}}-({{{2}}}<3)) -.4 round 0)
+({{{1}}}>250)* (2 - ( ({{{1}}}-1) /100 -.495 round 0) +( ({{{1}}}-1) /400 -.499 round 0)) )mod7 )/7 round 0}}
|-1={{{{{subst|}}}void|


case -1
6" is wrong]|{{{{{subst|}}}#expr:


}}{{{{{subst|}}}#expr:1=((365+{{{3}}}
6}}}}
+ ((( ( {{{1}}}-1 )mod4 = 0) and (( {{{1}}}-1 )mod100 != 0)) or ( {{{1}}}-1 )mod400 = 0))+6-((( 700000005.2+2.6*({{{2}}}+12*({{{2}}}<3))) round 0)+{{{3}}} + ( 1.25* ({{{1}}}-({{{2}}}<3)) -.4 round 0)
+({{{1}}}>250)* (2 - ( ({{{1}}}-({{{2}}}<3)) /100 -.495 round 0) +( ({{{1}}}-({{{2}}}<3)) /400 -.499 round 0)) )mod7 )/7 round 0}}
|1=1}}</includeonly><noinclude>


==Examples==
+ 3 ) / 7 round 0}}
*{{evd|week|2005|12|31}}, and is eqv. with {{evd|week|2006|1|0}}
</pre>
*{{evd|week|2006|1|1}}
*{{evd|week|2006|1|2}}


===Examples where the ISO year is three days into the next gregorian year ===
<pre>
*{{evd|week|2009|12|31}}
{{subst:eval|(
*{{evd|week|2010|1|1}}
*{{evd|week|2010|1|2}}
*'''{{evd|week|2010|1|3}}'''
*{{evd|week|2010|1|4}}


===Examples where the ISO year is three days into the previous gregorian year ===
{{subst:orddate|subst=subst:|{{subst:isoyear|{{{1}}}|6|5}}|{{subst:MJD2M|subst=subst:|{{subst:#expr:{{subst:YMD2MJD|subst=subst:|2006|6|5}} - {{subst:DOW|subst=subst:|2006|6|5}} + 4 }}}}|{{subst:MJD2D|subst=subst:|{{subst:#expr:{{subst:YMD2MJD|subst=subst:|2006|6|5}} - {{subst:DOW|subst=subst:|2006|6|5}} + 4 }}}}}}
*{{evd|week2|2008|12|28}}
*'''{{evd|week2|2008|12|29}}'''
*{{evd|week2|2008|12|30}}
*{{evd|week2|2008|12|31}}
*{{evd|week2|2009|1|1}}


This function do not adhere to the ISO standard (ISO 8601). Use {{tl|Week2}} instead if it should comply with ISO.
+ 3 ) / 7 round 0}}
</pre>


==More examples==
----
{{{{{subst|}}}MJD2Y|subst={{{subst|}}}|{{{{{subst|}}}#expr:( {{{{{subst|}}}YMD2MJD|subst={{{subst|}}}|2006|6|5}} - {{{{{subst|}}}DOW|subst={{{subst|}}}|2006|6|5}} ) + 4}}}}|6|8}}
----


*{{evd|week|1999|1|4}} {{weekdate|1999|1|4}}
*{{evd|week|2006|1|4}}
*{{evd|week|2006|1|5}}
*{{evd|week|2006|1|6}}
*{{evd|week|2006|1|7}}
*{{evd|week|2006|1|8}}
*{{evd|week|2006|1|9}}
*{{evd|week|2006|1|10}}
*{{evd|week|2006|1|16}}
*{{evd|week|2006|2|16}}
*{{evd|week|2010|1|4}}
*{{evd|week|2004|12|31}} {{weekdate|2004|12|31}}
*{{evd|week|2005|1|1}} {{weekdate|2005|1|1}}
*{{evd|week|2006|1|1}}
*{{evd|week|2007|12|30}}
*{{evd|week|2007|12|31}}
*{{evd|week|2008|1|1}}
*{{evd|week|2008|1|2}}
*{{evd|week|2008|1|3}}
*{{evd|week|2008|1|4}}
*{{evd|week|2010|2|28}}
*{{evd|week|2010|3|01}}
*{{evd|week|2010|3|02}}
*{{evd|week|2010|3|03}}
*{{evd|week|2010|3|04}}
*{{evd|week|2010|3|05}}
*{{evd|week|2010|3|06}}
*{{evd|week|2010|3|07}}
*{{evd|week|2010|3|08}}


<!--
<pre>
*{{subst:week|subst=subst:|2006|6|5}}
{{subst:isoyear|2006|6|5}}|{{subst:MJD2M|subst=subst:|{{subst:#expr:{{subst:YMD2MJD|subst=subst:|2006|6|5}} - {{subst:DOW|subst=subst:|2006|6|5}} + 4 }}}}|{{subst:MJD2D|subst=subst:|{{subst:#expr:{{subst:YMD2MJD|subst=subst:|2006|6|5}} - {{subst:DOW|subst=subst:|2006|6|5}} + 4 }}}}}}
-->


Compare:
*variable <nowiki>{{CURRENTWEEK}}</nowiki> gives {{CURRENTWEEK}}.


In the current method the ISO year minus the Gregorian year is made a switch index. The rest of the expression has to be put in two versions, for the values -1 and 0. If the index is 1 the week number is simply also 1.
</pre>
In the other method (first method of [http://meta.wikimedia.org/w/index.php?title=Template:Week&action=edit&oldid=374813]) the expression


(({{{2}}}=1)*({{{3}}}<4-( ( 1.25* ({{{1}}}-1) -.4 round 0)+({{{1}}}>250)* (2 - ( ({{{1}}}-1) /100 -.495 round 0) +( ({{{1}}}-1) /400 -.499 round 0) ) + 700000001 ) mod7)-({{{2}}}=12)*({{{3}}}>=35-( ( 1.25* {{{1}}} -.4 round 0)+({{{1}}}>250)* (2 - ( {{{1}}} /100 -.495 round 0) +( {{{1}}} /400 -.499 round 0) ) + 700000001 ) mod7)
*<nowiki>{{week|2006|6|5}}</nowiki> gives {{week|2006|6|5}}.


for the ISO year minus the Gregorian year is needed five times.
*{{#if:{{#ifexpr:({{#if:{{#ifexpr:Expression error: unrecognised punctuation character "{" - -676749 + 1}}|[expression "Expression error: unrecognised punctuation character "{" - -676749 + 1" is wrong]|{{{{{subst|}}}#expr:Expression error: unrecognised punctuation character "{" - -676749 + 1}}}} + 3 ) / 7 round 0}}|[expression "({{#if:{{#ifexpr:Expression error: unrecognised punctuation character "{" - -676749 + 1}}|[expression "Expression error: unrecognised punctuation character "{" - -676749 + 1" is wrong]|{{{{{subst|}}}#expr:Expression error: unrecognised punctuation character "{" - -676749 + 1}}}} + 3 ) / 7 round 0" is wrong]|{{{{{subst|}}}#expr:({{#if:{{#ifexpr:Expression error: unrecognised punctuation character "{" - -676749 + 1}}|[expression "Expression error: unrecognised punctuation character "{" - -676749 + 1" is wrong]|{{{{{subst|}}}#expr:Expression error: unrecognised punctuation character "{" - -676749 + 1}}}} + 3 ) / 7 round 0}}}}

*{{#if:{{#ifexpr:({{#if:{{#ifexpr:Expression error: unrecognised punctuation character "{" - -676749 + 1}}|[expression "Expression error: unrecognised punctuation character "{" - -676749 + 1" is wrong]|{{{{{subst|}}}#expr:Expression error: unrecognised punctuation character "{" - -676749 + 1}}}} + 3 ) / 7 round 0}}|[expression "({{#if:{{#ifexpr:Expression error: unrecognised punctuation character "{" - -676749 + 1}}|[expression "Expression error: unrecognised punctuation character "{" - -676749 + 1" is wrong]|{{{{{subst|}}}#expr:Expression error: unrecognised punctuation character "{" - -676749 + 1}}}} + 3 ) / 7 round 0" is wrong]|{{{{{subst|}}}#expr:({{#if:{{#ifexpr:Expression error: unrecognised punctuation character "{" - -676749 + 1}}|[expression "Expression error: unrecognised punctuation character "{" - -676749 + 1" is wrong]|{{{{{subst|}}}#expr:Expression error: unrecognised punctuation character "{" - -676749 + 1}}}} + 3 ) / 7 round 0}}}}

*{{s ubst:week|subst=subst:|2006|6|5}}

Compare:
*variable <nowiki>{{CURRENTWEEK}}</nowiki> gives {{CURRENTWEEK}}.


[[Category:Date computing template|{{PAGENAME}}]]
[[Category:Date computing template|{{PAGENAME}}]]
[[Category:Templates using ParserFunctions|{{PAGENAME}}]]
</noinclude>
</noinclude>

Latest revision as of 14:10, 16 November 2021


Examples[edit]

  • "{{week|2005|12|31}}" gives "52" [1], and is eqv. with "{{week|2006|1|0}}" gives "0" [2]
  • "{{week|2006|1|1}}" gives "0" [3]
  • "{{week|2006|1|2}}" gives "1" [4]

Examples where the ISO year is three days into the next gregorian year[edit]

  • "{{week|2009|12|31}}" gives "53" [5]
  • "{{week|2010|1|1}}" gives "0" [6]
  • "{{week|2010|1|2}}" gives "0" [7]
  • "{{week|2010|1|3}}" gives "0" [8]
  • "{{week|2010|1|4}}" gives "1" [9]

Examples where the ISO year is three days into the previous gregorian year[edit]

  • "{{week2|2008|12|28}}" gives "52" [10]
  • "{{week2|2008|12|29}}" gives "01" [11]
  • "{{week2|2008|12|30}}" gives "01" [12]
  • "{{week2|2008|12|31}}" gives "01" [13]
  • "{{week2|2009|1|1}}" gives "01" [14]

This function do not adhere to the ISO standard (ISO 8601). Use {{Week2}} instead if it should comply with ISO.

More examples[edit]

  • "{{week|1999|1|4}}" gives "1" [15] 1999-W01-1
  • "{{week|2006|1|4}}" gives "1" [16]
  • "{{week|2006|1|5}}" gives "1" [17]
  • "{{week|2006|1|6}}" gives "1" [18]
  • "{{week|2006|1|7}}" gives "1" [19]
  • "{{week|2006|1|8}}" gives "1" [20]
  • "{{week|2006|1|9}}" gives "2" [21]
  • "{{week|2006|1|10}}" gives "2" [22]
  • "{{week|2006|1|16}}" gives "3" [23]
  • "{{week|2006|2|16}}" gives "7" [24]
  • "{{week|2010|1|4}}" gives "1" [25]
  • "{{week|2004|12|31}}" gives "53" [26] 2004-W53-5
  • "{{week|2005|1|1}}" gives "0" [27] 2004-W53-6
  • "{{week|2006|1|1}}" gives "0" [28]
  • "{{week|2007|12|30}}" gives "52" [29]
  • "{{week|2007|12|31}}" gives "1" [30]
  • "{{week|2008|1|1}}" gives "1" [31]
  • "{{week|2008|1|2}}" gives "1" [32]
  • "{{week|2008|1|3}}" gives "1" [33]
  • "{{week|2008|1|4}}" gives "1" [34]
  • "{{week|2010|2|28}}" gives "8" [35]
  • "{{week|2010|3|01}}" gives "9" [36]
  • "{{week|2010|3|02}}" gives "9" [37]
  • "{{week|2010|3|03}}" gives "9" [38]
  • "{{week|2010|3|04}}" gives "9" [39]
  • "{{week|2010|3|05}}" gives "9" [40]
  • "{{week|2010|3|06}}" gives "9" [41]
  • "{{week|2010|3|07}}" gives "9" [42]
  • "{{week|2010|3|08}}" gives "10" [43]


Compare:

  • variable {{CURRENTWEEK}} gives 23.

In the current method the ISO year minus the Gregorian year is made a switch index. The rest of the expression has to be put in two versions, for the values -1 and 0. If the index is 1 the week number is simply also 1.

In the other method (first method of [44]) the expression

(({{{2}}}=1)*({{{3}}}<4-( ( 1.25* ({{{1}}}-1) -.4 round 0)+({{{1}}}>250)* (2 - ( ({{{1}}}-1) /100 -.495 round 0) +( ({{{1}}}-1) /400 -.499 round 0) ) + 700000001 ) mod7)-({{{2}}}=12)*({{{3}}}>=35-( ( 1.25* {{{1}}} -.4 round 0)+({{{1}}}>250)* (2 - ( {{{1}}} /100 -.495 round 0) +( {{{1}}} /400 -.499 round 0) ) + 700000001 ) mod7)

for the ISO year minus the Gregorian year is needed five times.