Template:Timestamp2MJD
Note: this template does not work on installations (as has been observed on Windows) where a number, before mod is applied, is reduced to php data-type "signed INT", i.e. a signed 32-bits integer [1], i.e. where mod gives wrong results for integers outside the range -2,147,483,648 through 2,147,483,647. This template applies mod to timestamps, which have 14 digits, five too many. It could be rewritten either to use Template:Mod (which uses "round"), or use "round" directly. Also replacing mod with fmod seems to work, if mw:Extension:ParserFunctions (extended) has been installed.
- This auxiliary template allows template:MJD (edit•talk•links•history) to operate on a single
"{{CURRENTTIMESTAMP|=}}"
gives "Template:CURRENTTIMESTAMP" [2] without risk of critical races: - 60592.156863426
Usage: {{Timestamp2MJD|YYYYMMDDhhmmss}}
, only non-negative whole numbers, almost no error
handling. Months are checked for plausibility, this catches incomplete timestamps hhmmss and
some variations of YYYYMMDDhmmss instead of YYYYMMDD0hmmss.
- {{
Timestamp2MJD|0
}} gives Expression error: Unrecognized word "badmonth". - {{
Timestamp2MJD|101223344|||=
}} gives -678940.05990741, NOT RECOMMENDED - {{
Timestamp2MJD|00000101000000|||=
}} gives -678941, minimal Gregorian date - {{
Timestamp2MJD|02000301000000|||=
}} gives -605833, see also{{YMD2MJD}}
- {{
Timestamp2MJD|18581115223344|||=
}} gives -1.0599074074074 - {{
Timestamp2MJD|18581116223344|||=
}} gives -0.05990740740741 - {{
Timestamp2MJD|18581117223344|||=
}} gives 0.94009259259259 - {{
Timestamp2MJD|18581118223344|||=
}} gives 1.9400925925926 - {{
Timestamp2MJD|(18581115223344 round -6)|||=
}} gives -2 - {{
Timestamp2MJD|(18581116223344 round -6)|||=
}} gives -1 - {{
Timestamp2MJD|(18581117223344 round -6)|||=
}} gives 0 - {{
Timestamp2MJD|(18581118223344 round -6)|||=
}} gives 1 - {{
Timestamp2MJD|(20241009034553 round -6)|||=
}} gives 60592
Test with subst and 20070321123457 (see edit box):
- 54180