Difference between revisions of "Template:Version to date"
(should work from 27 Feb 2013 (0.0.0) until 29 Feb 2400) |
(fixed an issue with invalid dates at the end of December; moved tests to documentation) |
||
Line 1: | Line 1: | ||
− | <includeonly> | + | <includeonly>{{#ifexpr: {{#vardefineecho:version | {{#explode: {{{1 | {{SUBPAGENAME}} }}} | . | -1 }} }} > -1 | |
− | {{#vardefine:leapDays | {{#expr: floor( ({{#var:version}} - | + | {{#vardefine:leapDays | {{#expr: floor( ({{#var:version}} {{#vardefineecho:offset|<!-- Offset for Version 0.0.0 :-->+ 56 <!-- Offset for next Feb 28 in leap year-->+ 365 - 59 }}) / (365 * 4) ) }} }}{{#vardefine:days | {{#expr: {{#var:version}} + 57}} }}{{#time: Y-m-d | {{#expr: 2013 + floor({{#var:days}} / 365)}}-{{#ifexpr: ({{#var:days}} - {{#var:leapDays}}) mod 365 > 333 | 12{{#vardefine:monthDays|333}} | |
− | {{#ifexpr: ({{#var:days}} | + | {{#ifexpr: ({{#var:days}} - {{#var:leapDays}}) mod 365 > 303 | 11{{#vardefine:monthDays|303}} | |
− | {{#ifexpr: ({{#var:days}} | + | {{#ifexpr: ({{#var:days}} - {{#var:leapDays}}) mod 365 > 272 | 10{{#vardefine:monthDays|272}} | |
− | {{#ifexpr: ({{#var:days}} | + | {{#ifexpr: ({{#var:days}} - {{#var:leapDays}}) mod 365 > 242 | 09{{#vardefine:monthDays|242}} | |
− | {{#ifexpr: ({{#var:days}} | + | {{#ifexpr: ({{#var:days}} - {{#var:leapDays}}) mod 365 > 211 | 08{{#vardefine:monthDays|211}} | |
− | {{#ifexpr: ({{#var:days}} | + | {{#ifexpr: ({{#var:days}} - {{#var:leapDays}}) mod 365 > 180 | 07{{#vardefine:monthDays|180}} | |
− | {{#ifexpr: ({{#var:days}} | + | {{#ifexpr: ({{#var:days}} - {{#var:leapDays}}) mod 365 > 150 | 06{{#vardefine:monthDays|150}} | |
− | {{#ifexpr: ({{#var:days}} | + | {{#ifexpr: ({{#var:days}} - {{#var:leapDays}}) mod 365 > 119 | 05{{#vardefine:monthDays|119}} | |
− | {{#ifexpr: ({{#var:days}} | + | {{#ifexpr: ({{#var:days}} - {{#var:leapDays}}) mod 365 > 89 | 04{{#vardefine:monthDays| 89}} | |
− | {{#ifexpr: ({{#var:days}} | + | {{#ifexpr: ({{#var:days}} - {{#var:leapDays}}) mod 365 > 58 | 03{{#vardefine:monthDays| 58}} | |
− | {{#ifexpr: ({{#var:days}} | + | {{#ifexpr: ({{#var:days}} - {{#var:leapDays}}) mod 365 > 30 | 02{{#vardefine:monthDays| 30}} | |
− | 01{{#vardefine:monthDays|-1}} }} }} }} }} }} }} }} }} }} }} }}-{{#expr: {{#var:days}} | + | 01{{#vardefine:monthDays|-1}} }} }} }} }} }} }} }} }} }} }} }}-{{#expr: ( ({{#var:days}} - {{#var:leapDays}}) mod 365) - {{#var:monthDays}} {{#ifexpr: ({{#var:version}} - 59 + 56 + 365) mod (365 * 4) = 0 | + 1}} }} }} |
− | | {{Error| No valid version number}} }} | + | | {{Error| No valid version number}} }}</includeonly><noinclude>{{Documentation}}</noinclude> |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | </noinclude> |
Revision as of 17:25, 1 November 2022
Summary
This template converts the last part of the version number, which represents the number of days since one of the first builds of RimWorld, into the date of the release of that particular version.
This templates takes leap years until Feb 28, 2400 into account.
Usage
Simply add {{Version to date}}
to any subpage with a name like "Version/<version number>" (e.g. Version/1.3.3069).
Alternatively you can simply add the the version number as the first parameter like {{Version to date|Version/1.3.3069}}
, {{Version to date|1.3.3069}}
or even {{Version to date|3069}}
.
Examples
The (fictional) '''version 0.0.0''' would have been released on {{#time: F j, Y | {{Version to date|0.0.0}} }}.
The (fictional) version 0.0.0 would have been released on February 27, 2013.
The current '''version {{Current Version}}''' has been released on {{#time: F j, Y | {{Version to date|{{Current Version}} }} }}.
The current version 1.5.4241 has been released on October 8, 2024.
Test cases
Specific versions
{{Version to date|1.3.3069}}
was released on 2021-07-24 and returns 2021-07-24
{{Version to date|1.4.3530}}
was released on 2022-10-28 and returns 2022-10-28
Special dates
Common year to leap year
{{Version to date|2498}}
should result in 2019-12-31 and returns: 2020-12-31
{{Version to date|2499}}
should result in 2020-01-01 and returns: 2020-01-01
February to March in leap year
{{Version to date|2557}}
should result in 2020-02-28 and returns: 2020-02-28
{{Version to date|2558}}
should result in 2020-02-29 and returns: 2020-02-29
{{Version to date|2559}}
should result in 2020-03-01 and returns: 2020-03-01
March to April in leap year
{{Version to date|2589}}
should result in 2020-03-31 and returns: 2020-03-31
{{Version to date|2590}}
should result in 2020-04-01 and returns: 2020-04-01
Leap year to common year
{{Version to date|2864}}
should result in 2020-12-31 and returns: 2021-12-31
{{Version to date|2865}}
should result in 2021-01-01 and returns: 2021-01-01
February to March in common year
{{Version to date|2923}}
should result in 2021-02-28 and returns: 2021-02-28
{{Version to date|2924}}
should result in 2021-03-01 and returns: 2021-03-01
March to April in common year
{{Version to date|2954}}
should result in 2021-03-31 and returns: 2021-03-31
{{Version to date|2955}}
should result in 2021-04-01 and returns: 2021-04-01
The above documentation is transcluded from Template:Version to date/doc. (edit | history) Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages. Please add categories to the /doc subpage. Subpages of this template. |