Compare commits
No commits in common. "12092ccb07f191f6af7017e02694e4d0c8266589" and "04d81d5fc02c98b54418d610d7c6be6ba72d919d" have entirely different histories.
12092ccb07
...
04d81d5fc0
|
@ -10,3 +10,8 @@ uk_tz = pytz.timezone("Europe/London")
|
|||
def uk_time(d: date, t: time) -> datetime:
|
||||
"""Combine time and date for UK timezone."""
|
||||
return uk_tz.localize(datetime.combine(d, t))
|
||||
|
||||
|
||||
def uk_midnight(d: date) -> datetime:
|
||||
"""Midnight UK time."""
|
||||
return uk_time(d, datetime.min.time())
|
||||
|
|
|
@ -32,7 +32,7 @@ from . import (
|
|||
thespacedevs,
|
||||
travel,
|
||||
uk_holiday,
|
||||
uk_tz,
|
||||
uk_midnight,
|
||||
waste_schedule,
|
||||
)
|
||||
from .types import Event, Holiday
|
||||
|
@ -125,11 +125,6 @@ def get_holidays(country: str, start_date: date, end_date: date) -> list[Holiday
|
|||
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(
|
||||
rrule: str, start: date, end: 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"])
|
||||
|
||||
return [
|
||||
i.date() if all_day else uk_tz.localize(i)
|
||||
for i in dateutil.rrule.rrulestr(rrule, dtstart=midnight(start)).between(
|
||||
midnight(start), midnight(end)
|
||||
i.date() if all_day else i
|
||||
for i in dateutil.rrule.rrulestr(rrule, dtstart=uk_midnight(start)).between(
|
||||
uk_midnight(start), uk_midnight(end)
|
||||
)
|
||||
]
|
||||
|
||||
|
|
Loading…
Reference in a new issue