m

    Matt Harvey

    3 years ago
    Good morning! Apologies if this is answered in the docs, I can't seem to find it. Prefect always seems to run in UTC, and so the
    CronClock
    needs to be set in UTC. Not a big deal, but is it possible to override the timezone? ๐Ÿ•
    Chris White

    Chris White

    3 years ago
    Hi Matt! Every Clock accepts a
    start_date
    keyword argument at initialization; if you pass a timezone-aware datetime / pendulum object, Prefect will respect that timezone for the clock / schedule. E.g.,
    from prefect.schedules.clocks import CronClock  
    import pendulum
    
    clock = CronClock("0 1 0 0 1/5", start_date=pendulum.now("US/Eastern"))
    next(clock.events()) 
    DateTime(2020, 1, 1, 1, 0, 0, tzinfo=Timezone('US/Eastern'))
    we should probably document this at the top level of the schedules / clock API documentation and as well as the concept docs
    @Marvin archive โ€œCan I override the timezone of a Prefect Clock?โ€
    Marvin

    Marvin

    3 years ago
    m

    Matt Harvey

    3 years ago
    Brilliant, thank you, Chris!