Compare commits

..

No commits in common. "12092ccb07f191f6af7017e02694e4d0c8266589" and "04d81d5fc02c98b54418d610d7c6be6ba72d919d" have entirely different histories.

2 changed files with 9 additions and 9 deletions

View file

@ -10,3 +10,8 @@ uk_tz = pytz.timezone("Europe/London")
def uk_time(d: date, t: time) -> datetime: def uk_time(d: date, t: time) -> datetime:
"""Combine time and date for UK timezone.""" """Combine time and date for UK timezone."""
return uk_tz.localize(datetime.combine(d, t)) return uk_tz.localize(datetime.combine(d, t))
def uk_midnight(d: date) -> datetime:
"""Midnight UK time."""
return uk_time(d, datetime.min.time())

View file

@ -32,7 +32,7 @@ from . import (
thespacedevs, thespacedevs,
travel, travel,
uk_holiday, uk_holiday,
uk_tz, uk_midnight,
waste_schedule, waste_schedule,
) )
from .types import Event, Holiday from .types import Event, Holiday
@ -125,11 +125,6 @@ def get_holidays(country: str, start_date: date, end_date: date) -> list[Holiday
return found return found
def midnight(d: date) -> datetime:
"""Convert from date to midnight on that day."""
return datetime.combine(d, datetime.min.time())
def dates_from_rrule( def dates_from_rrule(
rrule: str, start: date, end: date rrule: str, start: date, end: date
) -> typing.Sequence[datetime | date]: ) -> typing.Sequence[datetime | date]:
@ -137,9 +132,9 @@ def dates_from_rrule(
all_day = not any(param in rrule for param in ["BYHOUR", "BYMINUTE", "BYSECOND"]) all_day = not any(param in rrule for param in ["BYHOUR", "BYMINUTE", "BYSECOND"])
return [ return [
i.date() if all_day else uk_tz.localize(i) i.date() if all_day else i
for i in dateutil.rrule.rrulestr(rrule, dtstart=midnight(start)).between( for i in dateutil.rrule.rrulestr(rrule, dtstart=uk_midnight(start)).between(
midnight(start), midnight(end) uk_midnight(start), uk_midnight(end)
) )
] ]