aboutsummaryrefslogtreecommitdiff
path: root/backend/histplorer.py
diff options
context:
space:
mode:
authorTerry Truong <terry06890@gmail.com>2022-10-20 15:31:05 +1100
committerTerry Truong <terry06890@gmail.com>2022-10-20 15:31:05 +1100
commit83366605d1bd43c245c4c110fadfd1a6fd05d3c2 (patch)
treea7d0352d2a4d4e14b8113dcfdf28d06a06af20d4 /backend/histplorer.py
parentf09bfa345519f7d070ae9c7474ef8b4f91b22bae (diff)
Add gcal to client-side HistDates
Add YearDate and CalDate Restrict non-calendar HistDates to years before 4713 BC
Diffstat (limited to 'backend/histplorer.py')
-rwxr-xr-xbackend/histplorer.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/backend/histplorer.py b/backend/histplorer.py
index e5c6c5a..9f9e8ad 100755
--- a/backend/histplorer.py
+++ b/backend/histplorer.py
@@ -31,6 +31,7 @@ DEFAULT_REQ_EVENTS = 20
MAX_REQ_EXCLS = 100
MAX_REQ_SUGGS = 50
DEFAULT_REQ_SUGGS = 5
+MIN_CAL_YEAR = -4713 # Disallow within-year dates before this year
# Classes for objects sent as responses
class HistDate:
@@ -41,9 +42,9 @@ class HistDate:
- 'gcal' may be:
- True: Indicates a Gregorian calendar date
- False: Means the date should be converted and displayed as a Julian calendar date
- - None: 'month' and 'day' are None (used for dates before the Julian period starting year 4713 BCE)
+ - None: 'month' and 'day' are 1 (used for dates before the Julian period starting year 4713 BCE)
"""
- def __init__(self, gcal: bool | None, year: int, month: int | None = None, day: int | None = None):
+ def __init__(self, gcal: bool | None, year: int, month=1, day=1):
self.gcal = gcal
self.year = year
self.month = month
@@ -282,7 +283,10 @@ def eventEntryToResults(
if n is None:
continue
elif fmt == 0:
- newDates[i] = HistDate(None, n)
+ if n >= MIN_CAL_YEAR:
+ newDates[i] = HistDate(True, n, 1, 1)
+ else:
+ newDates[i] = HistDate(None, n)
elif fmt == 1:
newDates[i] = HistDate(False, *jdnToJulian(n))
elif fmt == 2: