mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2026-01-18 16:52:51 +00:00
cope with pre 2000 years
This commit is contained in:
@@ -56,9 +56,12 @@ def make_valid_date(walletname, date):
|
||||
m = int(data['month'])
|
||||
y = int(data['year'])
|
||||
|
||||
# Two-digit year handling
|
||||
if y < 2000:
|
||||
y = y + 2000
|
||||
# Two-digit year handling: Use 70 as the pivot year (70-99 -> 19xx, 00-69 -> 20xx)
|
||||
if y < 100:
|
||||
if y >= 70:
|
||||
y = 1900 + y
|
||||
else:
|
||||
y = 2000 + y
|
||||
|
||||
try:
|
||||
samedate = datetime.date(y, m, d)
|
||||
@@ -99,49 +102,6 @@ def make_valid_date(walletname, date):
|
||||
|
||||
return None
|
||||
|
||||
|
||||
# def make_valid_date(walletname, date):
|
||||
# """Take whatever garbage some fool has typed in and try to make it into a valid ISO-format date
|
||||
# """
|
||||
# datestr = date.replace(".", "-").replace("/", "-")
|
||||
# try:
|
||||
# samedate = datetime.date.fromisoformat(datestr)
|
||||
# return samedate
|
||||
# except ValueError:
|
||||
# # Could be in std euro format e.g. 14/07/2023
|
||||
# match = re.search(r'(\d{1,2})/(\d{1,2})/(\d{2,4})', datestr)
|
||||
# if match:
|
||||
# d = int(match.group(1))
|
||||
# m = int(match.group(2))
|
||||
# y = int(match.group(3))
|
||||
# if y<2000:
|
||||
# y = y + 2000
|
||||
# try:
|
||||
# samedate = datetime.date(y, m, d)
|
||||
# print(f"- - Warning, not in ISO format. '{datestr=}' but we tried to cope: {samedate.isoformat()} {walletname}")
|
||||
# return samedate
|
||||
# except:
|
||||
# print(f"! - Fail, tried to decompose date in dd/mm/yyyy format but failed: {datestr=} ")
|
||||
# return None
|
||||
# # probably a single digit day number or month number
|
||||
# match = re.search(r'(\d{4})-(\d{1,2})-(\d{1,2})', datestr)
|
||||
# if match:
|
||||
# y = int(match.group(1))
|
||||
# m = int(match.group(2))
|
||||
# d = int(match.group(3))
|
||||
# try:
|
||||
# samedate = datetime.date(y, m, d)
|
||||
# print(f"- - Warning, 1 digit only for month or day '{datestr=}' but we coped: {samedate.isoformat()} ")
|
||||
# return samedate
|
||||
# except:
|
||||
# print(f"! - Fail, tried to decompose date in yyyy-mm-d or yyy-m-dd format but failed: {datestr=} ")
|
||||
# return None
|
||||
|
||||
# if datestr: # might have been None
|
||||
# if datestr != "None":
|
||||
# print(f"! - Failed to understand date, none of our tricks worked {datestr=} ")
|
||||
# return None
|
||||
|
||||
archaic_wallets = [
|
||||
'1984AndysNotebook',
|
||||
'1984BrownLandscapeNotebook',
|
||||
|
||||
Reference in New Issue
Block a user