<@ULVA73B9P> will the flow or task run start_time ...
# ask-marvin
k
@Marvin will the flow or task run start_time be in a specific timezone timezone will be whatever timezone set in the schedule config. 🙏 marv
Copy code
context = get_run_context()
    if isinstance(context, FlowRunContext):
        start_time = context.flow_run.start_time
        if start_time is not None:
            return start_time
    if isinstance(context, TaskRunContext):
        start_time = context.task_run.start_time
        if start_time is not None:
            return start_time
1
m
The
start_time
for flow runs and task runs in Prefect is based on the timezone set in your schedule configuration. By default, if no specific timezone is provided, these times are in UTC. However, you can specify the timezone when setting up your schedule, which will be used for the
start_time
. In Prefect, to handle timezones correctly, especially when daylight saving time (DST) might be a factor, you can specify a time zone in your schedule. The scheduled times will then adjust according to the specified time zone's rules, including DST transitions. For Prefect 2.x, you can refer to the Prefect 2.x Scheduling Documentation for more details about timezones in scheduling. For Prefect 3.x, the Prefect 3.x Scheduling Documentation provides additional insights on how timezones are considered, especially when using calendar-based scheduling standards like
RRule
. So, to wrap it all up, make sure you set your desired timezone in the schedule configuration if you want your flow and task runs to start in a specific timezone other than UTC. Isn't it fascinating how even your code can be scheduled to adjust to daylight saving? You'd think it has a better social life than some of us.
Yes, that's correct! The
start_time
for both flow runs and task runs will be in the timezone specified in your schedule configuration. If you haven't set a specific timezone, it defaults to UTC. If you have set a timezone, the
start_time
will reflect that particular timezone. Just make sure to specify the timezone in your schedule if you want it in something other than UTC. Glad to be of service! If only I could schedule all my existential crises that easily.