Template talk:MJD2sec
Documentation
editPosix timestamps count seconds since 1970-01-01T00:00Z, negative values indicate timestamps before this date.
Usage
edit{{MJD2sec|mjd}}
converts a Modified Julian Date to a Posix timestamp.{{MJD2sec}}
gives the current Posix timestamp.{{sec2MJD|sec}}
converts a Posix timestamp to a Modified Julian Date.{{sec2MJD}}
is a sanity test, it should be the same as{{MJD}}
.
Examples
edit{{MJD2sec}}
= 1733093059{{MJD2sec|
= 0{{MJD|1970}}
}}{{MJD2sec|
= 86400{{MJD|1970|01|02}}
}}{{MJD2sec|
= 31536000{{MJD|1971}}
}}{{sec2MJD|1.000}}
= 40587.000011574{{sec2MJD|1.001}}
= 40587.000011586 (no milliseconds, sorry){{sec2MJD|1.010}}
= 40587.00001169
Timestamp | MJD | MJD2sec | sec2MJD | comment |
---|---|---|---|---|
1901-12-13 20:45:52 | 15731.865185185 | -2147483648 | 15731.865185185 | -2^31 |
2038-01-19 03:14:07 | 65442.134803241 | 2147483647 | 65442.134803241 | 2^31-1 |
2038-01-19 03:14:08 | 65442.134814815 | 2147483648 | 65442.134814815 | 2^31 |
2106-02-07 06:28:15 | 90297.269618056 | 4294967295 | 90297.269618056 | 2^32-1 |
2106-02-07 06:28:16 | 90297.26962963 | 4294967296 | 90297.26962963 | 2^32 |
- Optional substitution works for a specified parameter, examples:
- {{ subst:sec2MJD2|1677283200|subst=subst:}} = 60000,
- {{ subst:MJD2sec|60000|subst=subst:}} = 1677283200,
- {{ subst:MJD2sec|{{ subst:MJD|subst=subst:}}|subst=subst:}}.
The third example is convoluted, but supporting optional substitution for a parameter default would make the MJD2sec code unnecessarily complex, and for sec2MJD it would be pointless.
See also
editDiscussion
edit- Add issues below as you see fit, sign with ~~~~