Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Julian Day
#14
Well, I pondered this for quite some time and kept coming back to the same thought, if you follow the rules for a leap year,

the same rules should apply for negative years.
Using Mr. Meuus' formula, this turns out to be true, so the 'simple' fix for the testing portion was to cheat Pythons 'calendar' library.

Substitute this line

days_in_month = monthrange(my_year, my_month)
with this line

days_in_month = monthrange(abs(my_year), my_month)
Using Jean Meeus' examples, the following now compute correctly:
 2000 Jan  1.5      2451545.0
 1987 Jan 27.0      2446822.5
 1987 Jun 19.5      2446966.0
 1988 Jan 27.0      2447187.5
 1900 Jan  1.0      2415020.5
 1600 Jan  1.0      2305447.5
 1600 Dec 31.0      2305812.5
  837 Apr 10.3      2026871.8
-1000 Jul 12.5      1356001.0
-1000 Feb 29.0      1355855.5    ** Note this results in an error, as the year 1000 (-1000) is not a leap year.
-1001 Aug 17.9      1355671.4
-4712 Jan  1.5            0.0

I was all set to do my victory dance until I tried the date 29 Feb 0, which should be a leap year and in fact, by the formula should be JD 1721116.5.... Darn that 'calendar' for starting at year 1.

Well some progress is better than no progress  :smash:
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition


Messages In This Thread
Julian Day - by sparkz_alot - Oct-06-2016, 03:39 PM
RE: Julian Day - by j.crater - Oct-06-2016, 06:15 PM
RE: Julian Day - by sparkz_alot - Oct-06-2016, 08:34 PM
RE: Julian Day - by j.crater - Oct-06-2016, 08:38 PM
RE: Julian Day - by Skaperen - Oct-07-2016, 04:17 AM
RE: Julian Day - by sparkz_alot - Oct-07-2016, 02:25 PM
RE: Julian Day - by Skaperen - Oct-08-2016, 01:05 AM
RE: Julian Day - by sparkz_alot - Oct-08-2016, 01:41 AM
RE: Julian Day - by Skaperen - Oct-08-2016, 04:11 AM
RE: Julian Day - by sparkz_alot - Oct-08-2016, 02:09 PM
RE: Julian Day - by Skaperen - Oct-09-2016, 02:27 AM
RE: Julian Day - by sparkz_alot - Oct-09-2016, 02:37 PM
RE: Julian Day - by Skaperen - Oct-10-2016, 02:27 AM
RE: Julian Day - by sparkz_alot - Oct-12-2016, 04:42 PM
RE: Julian Day - by Skaperen - Oct-13-2016, 03:32 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020