[issue829370] math.signum(int)

Frank report at bugs.python.org
Thu Mar 15 15:17:17 CET 2012


Frank <frank.breitling at gmx.de> added the comment:

Here an example where the signum function provides an elegant way to calculate the Julian date:

def julian_date(YY,MM,DD,HR,Min,Sec,UTcor):
     return 367*YY - (7*(YY+((MM+9)/12))/4) + (275*MM/9)+ DD + 1721013.5 + UTcor/24 - 0.5*sign((100*YY)+MM-190002.5) + 0.5 + HR/24.0 + Min/(60.0*24.0) + Sec/(3600.0*24.0)

http://aa.usno.navy.mil/faq/docs/JD_Formula.php
http://www.krioma.net/blog/2011/09/python_julian_date.php

By the way Julian date should be part of the time or datetime module.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue829370>
_______________________________________


More information about the Python-bugs-list mailing list