Howdy, how do i set the schedule in New York times...
# prefect-community
d
Howdy, how do i set the schedule in New York times
Copy code
schedules.Schedule(
        # fire every day
        clocks=[schedules.clocks.IntervalClock(timedelta(days=1))],
        # but only on weekdays
        filters=[filters.is_weekday],
        # and only at 8.15am or 3pm
        or_filters=[
            filters.between_times(pendulum.time(hour=8, minute=15), pendulum.time(hour=8, minute=15)),
            filters.between_times(pendulum.time(hour=9, minute=30), pendulum.time(hour=9,minute=30)),
            filters.between_times(pendulum.time(hour=15, minute=50), pendulum.time(hour=15,minute=50)),
            filters.between_times(pendulum.time(hour=16), pendulum.time(hour=16)),
        ],
        not_filters=[
            filters.between_dates(12, 25, 12, 25)
        ]
    )
z
Hi @DiffyBron! You can pin a schedule to a specific timezone by providing a time zone-scoped
start_time
to your
IntervalClock
. This should be fairly easy to achieve using pendulum e.g.,
Copy code
pendulum.datetime(2019, 1, 1, tz='America/New York')
d
Hi Zach, I've noticed that
IntervalClock
does not seem to have start_time, should i just set
start_date
instead?
Copy code
def __init__(
        self,
        interval: timedelta,
        start_date: datetime = None,
        end_date: datetime = None,
    ):
z
Yep yep! So your interval clock should look something like:
schedules.clocks.IntervalClock(start_date=pendulum.datetime(2019, 1, 1, tz='America/New York', interval=timedelta(days=1))
Apologies @DiffyBron, just noticed what you meant. You're absolutely right-- it should be
start_date
instead of
start_time
👍 1