Template:MonthDiff: Difference between revisions

m
no edit summary
(Undo revision 300802 by Pholin (talk))
Tag: Undo
mNo edit summary
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly>{{#ifeq:{{#expr: trunc({{{4}}}+{{{5}}}/12+{{{6}}}/(30*12)-({{{1}}}+{{{2}}}/12+{{{3}}}/(30*12)))}} years|0 years||{{#ifeq:{{#expr: trunc({{{4}}}+{{{5}}}/12+{{{6}}}/(30*12)-({{{1}}}+{{{2}}}/12+{{{3}}}/(30*12)))}} years|1 years|1 year|{{#expr: trunc({{{4}}}+{{{5}}}/12+{{{6}}}/(30*12)-({{{1}}}+{{{2}}}/12+{{{3}}}/(30*12)))}} years}}}} {{#ifeq:{{#expr:{{{4}}}*12+{{{5}}}+{{{6}}}/30-({{{1}}}*12+{{{2}}}+{{{3}}}/30)-(trunc({{{4}}}+{{{5}}}/12+{{{6}}}/(30*12)-({{{1}}}+{{{2}}}/12+{{{3}}}/(30*12))))*12round0}} months|1 months|1 month|{{#expr:{{{4}}}*12+{{{5}}}+{{{6}}}/30-({{{1}}}*12+{{{2}}}+{{{3}}}/30)-(trunc({{{4}}}+{{{5}}}/12+{{{6}}}/(30*12)-({{{1}}}+{{{2}}}/12+{{{3}}}/(30*12))))*12round0}} months}}</includeonly><noinclude>
<includeonly>{{#ifeq:{{#expr: trunc({{{4}}}+{{{5}}}/12+{{{6}}}/(30*12)-({{{1}}}+{{{2}}}/12+{{{3}}}/(30*12)))}} years|0 years||{{#ifeq:{{#expr: trunc({{{4}}}+{{{5}}}/12+{{{6}}}/(30*12)-({{{1}}}+{{{2}}}/12+{{{3}}}/(30*12)))}} years|1 years|1 year{{{7|}}}|{{#expr: trunc({{{4}}}+{{{5}}}/12+{{{6}}}/(30*12)-({{{1}}}+{{{2}}}/12+{{{3}}}/(30*12)))}} years{{{7|}}}}}}} {{#ifeq:{{#expr:{{{4}}}*12+{{{5}}}+{{{6}}}/30-({{{1}}}*12+{{{2}}}+{{{3}}}/30)-(trunc({{{4}}}+{{{5}}}/12+{{{6}}}/(30*12)-({{{1}}}+{{{2}}}/12+{{{3}}}/(30*12))))*12round0}} months|1 months|1 month|{{#expr:{{{4}}}*12+{{{5}}}+{{{6}}}/30-({{{1}}}*12+{{{2}}}+{{{3}}}/30)-(trunc({{{4}}}+{{{5}}}/12+{{{6}}}/(30*12)-({{{1}}}+{{{2}}}/12+{{{3}}}/(30*12))))*12round0}} months}}</includeonly><noinclude>
This templates allows you to (approximately) calculate the amount of years and months between two dates.
This templates allows you to (approximately) calculate the amount of years and months between two dates.


Line 7: Line 7:


For example, <code><nowiki>{{MonthDiff|2395|9|5|{{CurrentStarYear}}|{{CURRENTMONTH}}|{{CURRENTDAY2}}}}</nowiki></code> produces '''{{MonthDiff|2395|9|5|{{CurrentStarYear}}|{{CURRENTMONTH}}|{{CURRENTDAY2}}}}'''.
For example, <code><nowiki>{{MonthDiff|2395|9|5|{{CurrentStarYear}}|{{CURRENTMONTH}}|{{CURRENTDAY2}}}}</nowiki></code> produces '''{{MonthDiff|2395|9|5|{{CurrentStarYear}}|{{CURRENTMONTH}}|{{CURRENTDAY2}}}}'''.
If you want to seperate the years and months with a character or word, simply add another argument to the template: <code><nowiki>{{MonthDiff|2394|2|12|2396|15|4|,}}</nowiki></code> which produces '''{{MonthDiff|2394|2|12|2396|7|15|,}}'''. Or use <code><nowiki>{{MonthDiff|2394|2|12|2396|15|4| and}}</nowiki></code> to get '''{{MonthDiff|2392|2|12|2396|12|4| and}}'''.


'''NOTE:''' This does not error check at all.</noinclude>
'''NOTE:''' This does not error check at all.</noinclude>
960

edits