Python: No longer limited to years 0000..9999.

I ported the NOVAS C 3.1 functions julian_date and cal_date to Python,
and removed the dependence on the standard datetime class for calculating UT.
Now we can create Time objects for a much wider range of year values.

Simplified the julian_date formula in C and C#.

In the Python version, I had to account for a difference
in the way integer division works for negative numbers.
In Python, integer division always rounds down, not toward
zero like it does in C/C#. So I reworked the formulas to
avoid dividing a negative integer (month-14), dividing the
positive quantity (14-month) instead and toggling addition
of the term with subtraction of the term.

I use the reworked (14-month) version in C and C# for consistency.
Also, the formatting of the formula was wacky and didn't make sense,
so now it easier to read and understand.

The Python regex for parsing dates has been expanded to allow
years before 0 and after 9999.
Allow converting Python Time to string for years before 0 and after 9999.
This commit is contained in:
Don Cross
2022-10-06 10:56:17 -04:00
parent 1327730324
commit 409e490728
10 changed files with 210 additions and 70 deletions

View File

@@ -917,7 +917,7 @@ The value of the calling object is not modified. This function creates a brand n
| Type | Parameter | Description |
| --- | --- | --- |
| `int` | `year` | The UTC 4-digit year value, e.g. 2019. |
| `int` | `year` | The UTC year value, e.g. 2019. |
| `int` | `month` | The UTC month in the range 1..12. |
| `int` | `day` | The UTC day of the month, in the range 1..31. |
| `int` | `hour` | The UTC hour, in the range 0..23. |