Returns a date corresponding to the given Julian day number.
(n)
| 278 | |
| 279 | #More conversion functions. |
| 280 | def DateFromJDNumber(n): |
| 281 | """Returns a date corresponding to the given Julian day number.""" |
| 282 | if not isinstance(n, int): |
| 283 | raise TypeError, "%s is not an integer." % str(n) |
| 284 | |
| 285 | a = n + 32044 |
| 286 | b = (4*a + 3)//146097 |
| 287 | c = a - (146097*b)//4 |
| 288 | d = (4*c + 3)//1461 |
| 289 | e = c - (1461*d)//4 |
| 290 | m = (5*e + 2)//153 |
| 291 | |
| 292 | ret = Date() |
| 293 | ret.day = e + 1 - (153*m + 2)//5 |
| 294 | ret.month = m + 3 - 12*(m//10) |
| 295 | ret.year = 100*b + d - 4800 + m/10 |
| 296 | return ret |
| 297 | |
| 298 | def DateFromCOM(t): |
| 299 | """Converts a COM time directly into the Date format.""" |