Convert Rdate object to keep working
This commit is contained in:
parent
73aa0dd2a1
commit
7800a157bf
@ -63,19 +63,25 @@ def cast(value: str, guesses: Set) -> CastValue:
|
|||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
class Rdate(datetime.date):
|
class Rdate:
|
||||||
'''Represents a date'''
|
'''Represents a date'''
|
||||||
|
|
||||||
def __init__(self, date):
|
def __init__(self, date):
|
||||||
'''date: A string representing a date'''
|
'''date: A string representing a date'''
|
||||||
if not isinstance(date, Rstring):
|
r = _date_regexp.match(date)
|
||||||
date = Rstring(date)
|
if not r:
|
||||||
|
raise ValueError(f'{date} is not a valid date')
|
||||||
|
|
||||||
self.intdate = date.getDate()
|
year = int(r.group(1))
|
||||||
self.day = self.intdate.day
|
month = int(r.group(3))
|
||||||
self.month = self.intdate.month
|
day = int(r.group(5))
|
||||||
self.weekday = self.intdate.weekday()
|
d = datetime.date(year, month, day)
|
||||||
self.year = self.intdate.year
|
|
||||||
|
self.intdate = d
|
||||||
|
self.day = d.day
|
||||||
|
self.month = d.month
|
||||||
|
self.weekday = d.weekday()
|
||||||
|
self.year = d.year
|
||||||
|
|
||||||
def __hash__(self):
|
def __hash__(self):
|
||||||
return self.intdate.__hash__()
|
return self.intdate.__hash__()
|
||||||
|
Loading…
Reference in New Issue
Block a user