From 83366605d1bd43c245c4c110fadfd1a6fd05d3c2 Mon Sep 17 00:00:00 2001 From: Terry Truong Date: Thu, 20 Oct 2022 15:31:05 +1100 Subject: Add gcal to client-side HistDates Add YearDate and CalDate Restrict non-calendar HistDates to years before 4713 BC --- backend/histplorer.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'backend/histplorer.py') 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: -- cgit v1.2.3