How to consider daylight savings time when using cron schedule in Airflow

南笙酒味 提交于 2019-11-29 11:57:00

As you correctly noted, it is not possible to account for the daylight saving time (DST) if you use a cron schedule. But, since Airflow 1.10, instead of a cron schedule you can use time-zone aware datetime objects, which account for DST [1]:

import pendulum

local_tz = pendulum.timezone("Europe/Amsterdam")

default_args=dict(
    start_date=datetime(2016, 1, 1, tzinfo=local_tz),
    owner='Airflow'
)

dag = DAG('my_tz_dag', default_args=default_args)
op = DummyOperator(task_id='dummy', dag=dag)
print(dag.timezone) # <Timezone [Europe/Amsterdam]>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!