Difference between revisions of "Template:Age in weeks"

From blackwiki
Jump to navigation Jump to search
blackwiki>MusikAnimal
(Adding {{pp-template}} (TW))
blackwiki>Nsaa
(Create a document page)
Line 1: Line 1:
<noinclude>{{pp-template|small=yes}}</noinclude><noinclude>This template returns the number of weeks that have elapsed between two dates. If the second set of parameters is not included it will automatically calculate the days between a given date and today. To use type: '''<nowiki>{{Age in weeks|month1= |day1= |year1= |month2= |day2= | year2=}}</nowiki>'''
+
<includeonly>{{#expr:floor {{#expr:
</noinclude><includeonly>{{#expr:floor {{#expr:
 
 
           (
 
           (
 
         + {{Gregorian serial date
 
         + {{Gregorian serial date
Line 14: Line 13:
 
           )  
 
           )  
 
         / 7
 
         / 7
           }} }}</includeonly><noinclude>[[Category:Date mathematics templates|{{PAGENAME}}]]
+
           }} }}</includeonly><noinclude>
 +
{{documentation}}
 
</noinclude>
 
</noinclude>

Revision as of 19:06, 2 February 2015

Template documentation[view] [edit] [history] [purge]

This template returns the number of weeks that have elapsed between two dates. If the second set of parameters is not included it will automatically calculate the days between a given date and today.

Usage

Each date can be entered in a single parameter, or each date can be entered as three parameters: year, month, day.

  • {{age in weeks|month1=6|day1=14|year1=1946|month2=8|day2=19|year2=1946}} → 9
  • {{age in weeks|1946|6|14|1946|8|19}} → 0
  • {{age in weeks|1946-6-14|1946-8-19}} → 0
  • {{age in weeks|14 June 1946|Aug 19, 1946}} → 0
  • {{age in weeks|month1=11|day1=07|year1=2012}} → 669
  • {{age in weeks|7 November 2012}} → 0

An error is shown if an entered date is not valid (1900 was not a leap year).

  • {{age in weeks|31 January 1899|29 February 1900}}Error: Second date should be year, month, day