mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add a is_undefined_date method to utils.date
This commit is contained in:
parent
e24f359a84
commit
f8182c3804
@ -46,6 +46,14 @@ local_tz = _local_tz = SafeLocalTimeZone()
|
|||||||
|
|
||||||
UNDEFINED_DATE = datetime(101,1,1, tzinfo=utc_tz)
|
UNDEFINED_DATE = datetime(101,1,1, tzinfo=utc_tz)
|
||||||
|
|
||||||
|
def is_date_undefined(qt_or_dt):
|
||||||
|
d = qt_or_dt
|
||||||
|
if hasattr(d, 'toString'):
|
||||||
|
d = datetime(d.year(), d.month(), d.day(), tzinfo=utc_tz)
|
||||||
|
return d.year == UNDEFINED_DATE.year and \
|
||||||
|
d.month == UNDEFINED_DATE.month and \
|
||||||
|
d.day == UNDEFINED_DATE.day
|
||||||
|
|
||||||
def parse_date(date_string, assume_utc=False, as_utc=True, default=None):
|
def parse_date(date_string, assume_utc=False, as_utc=True, default=None):
|
||||||
'''
|
'''
|
||||||
Parse a date/time string into a timezone aware datetime object. The timezone
|
Parse a date/time string into a timezone aware datetime object. The timezone
|
||||||
|
Loading…
x
Reference in New Issue
Block a user