False
"""
- now = now_pacific()
tz = time.tzinfo
- return datetime.datetime.combine(now, time, tz)
+ return datetime.datetime.combine(now_pacific(), time, tz)
-def date_and_time_to_datetime(
- date: datetime.date, time: datetime.time
-) -> datetime.datetime:
+def date_and_time_to_datetime(date: datetime.date, time: datetime.time) -> datetime.datetime:
"""
Given a date and time, merge them and return a datetime.
return datetime_to_date_and_time(dt)[1]
-class TimeUnit(enum.Enum):
+class TimeUnit(enum.IntEnum):
"""An enum to represent units with which we can compute deltas."""
MONDAYS = 0
@classmethod
def is_valid(cls, value: Any):
- if type(value) is int:
- return value in cls._value2member_map_
- elif type(value) is TimeUnit:
- return value.value in cls._value2member_map_
- elif type(value) is str:
- return value in cls._member_names_
+ if isinstance(value, int):
+ return cls(value) is not None
+ elif isinstance(value, TimeUnit):
+ return cls(value.value) is not None
+ elif isinstance(value, str):
+ return cls.__members__[value] is not None
else:
print(type(value))
return False
-def n_timeunits_from_base(
- count: int, unit: TimeUnit, base: datetime.datetime
-) -> datetime.datetime:
+def n_timeunits_from_base(count: int, unit: TimeUnit, base: datetime.datetime) -> datetime.datetime:
"""Return a datetime that is N units before/after a base datetime.
e.g. 3 Wednesdays from base datetime, 2 weeks from base date, 10
years before base datetime, 13 minutes after base datetime, etc...
base += timedelta
if base.year != old_year:
skips = holidays.US(years=base.year).keys()
- if (
- base.weekday() < 5
- and datetime.date(base.year, base.month, base.day) not in skips
- ):
+ if base.weekday() < 5 and datetime.date(base.year, base.month, base.day) not in skips:
count -= 1
return base
date_time_separator=date_time_separator,
include_timezone=include_timezone,
include_dayname=include_dayname,
+ use_month_abbrevs=use_month_abbrevs,
include_seconds=include_seconds,
include_fractional=include_fractional,
twelve_hour=twelve_hour,
date_time_separator=date_time_separator,
include_timezone=include_timezone,
include_dayname=include_dayname,
+ use_month_abbrevs=use_month_abbrevs,
include_seconds=include_seconds,
include_fractional=include_fractional,
twelve_hour=twelve_hour,
'1d 10m'
"""
- return describe_duration_briefly(
- int(delta.total_seconds())
- ) # Note: drops milliseconds
+ return describe_duration_briefly(int(delta.total_seconds())) # Note: drops milliseconds
if __name__ == '__main__':