Paste number 73536: python Julian Day and Modified Julian Day functions

Index of paste annotations: 2 | 1

Paste number 73536: python Julian Day and Modified Julian Day functions
Pasted by: sbp
When:1 year, 2 months ago
Share:Tweet this! | http://paste.lisp.org/+1KQO
Channel:#swhack
Paste contents:
Raw Source | XML | Display As
>>> import time
>>> def jdn(): 
...    year, month, day = time.gmtime()[:3]
...    a = (14 - month) // 12
...    y = year + 4800 - a
...    m = month + (12 * a) - 3
...    p = day + (((153 * m) + 2) // 5) + (365 * y)
...    q = (y // 4) - (y // 100) + (y // 400) - 32045
...    return p + q
... 
>>> jdn()
2454845
>>> def mjd(): 
...    return jdn() - 2400000.5
... 
>>> mjd()
54844.5
>>> 

Annotations for this paste:

Annotation number 2: Yo p, welcome to lisppaste. Your gregorian carreer has ended.
Pasted by: [bjoern]
When:1 year, 2 months ago
Share:Tweet this! | http://paste.lisp.org/+1KQO/2
Paste contents:
Raw Source | Display As
no text.

Annotation number 1: Modified Julian Day Number, rather
Pasted by: sbp
When:1 year, 2 months ago
Share:Tweet this! | http://paste.lisp.org/+1KQO/1
Paste contents:
Raw Source | Display As
>>> import math
>>> def mjdn(): 
...    return int(math.floor(jdn() - 2400000.5))
... 
>>> mjdn()
54844

Colorize as:
Show Line Numbers
Index of paste annotations: 2 | 1

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.