def _get_this_week_end_utc_time_of_week(nz: datetime.datetime or None = None): if nz is None: nz = datetime.datetime.now(tz=pytz.timezone('US/Eastern')) end = (nz - timedelta(days=nz.weekday() - 4, hours=nz.hour - 17, minutes=nz.minute, seconds=nz.second, microseconds=nz.microsecond)) utc_end = end.astimezone(pytz.utc).replace(tzinfo=None) return utc_end
def _get_this_week_start_utc_time_of_week(nz: datetime.datetime or None = None): if nz is None: nz = datetime.datetime.now(tz=pytz.timezone('nz')) start = (nz - timedelta(days=nz.weekday(), hours=nz.hour - 9, minutes=nz.minute, seconds=nz.second, microseconds=nz.microsecond)) utc_start = start.astimezone(pytz.utc).replace(tzinfo=None) return utc_start