https://prefect.io logo
m

Marco Palmeri

01/21/2021, 8:50 PM
Hi Prefect folks. Quick question. Does the prefect.context.today variable respect the timezone as specified when instantiating a Schedule?
z

Zanie

01/21/2021, 8:58 PM
Hi Marco — they are always UTC. From the flow runner code:
Copy code
now = pendulum.now("utc")
        dates = {
            "date": now,
            "today": now.strftime("%Y-%m-%d"),
            "yesterday": now.add(days=-1).strftime("%Y-%m-%d"),
            "tomorrow": now.add(days=1).strftime("%Y-%m-%d"),
            "today_nodash": now.strftime("%Y%m%d"),
            "yesterday_nodash": now.add(days=-1).strftime("%Y%m%d"),
            "tomorrow_nodash": now.add(days=1).strftime("%Y%m%d"),
        }
m

Marco Palmeri

01/21/2021, 8:59 PM
Thanks!
j

Jeremiah

01/21/2021, 8:59 PM
Yup, one additional note - that
date
variable in context is a pendulum object, so you could load it into any time zone. I think you’d do something like this:
Copy code
prefect.context.date.in_tz('EST')
👍 1
m

Marco Palmeri

01/21/2021, 9:02 PM
@Jeremiah is date "now"?
j

Jeremiah

01/21/2021, 9:03 PM
yes
Just in a format you can manipulate to a different timezone if you choose
m

Marco Palmeri

01/21/2021, 9:03 PM
perfect
thanks