[
https://issues.apache.org/jira/browse/AIRFLOW-3928?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16774930#comment-16774930
]
Ash Berlin-Taylor commented on AIRFLOW-3928:
--------------------------------------------
We don't have a pre-baked one that includes the dashes, but we added/changed
something like this in [https://github.com/apache/airflow/pull/4323/files]
This changed {{\{\{ts_nodash}}}} to not have the TZ (20150101T000000), and
added {{\{\{ts_nodash_with_tz\}\}}} to include the tz (20150101T000000+0000)
If you want the dashes but no TZ you can use this macro {{
execution_date.strftime("%Y-%m-%dT%H:%M:%S") }}.
You could "tidy" this up if you use it a lot by providing
{{user_defined_macros}} on the dag:
{code:file=dag.py}
from jinja2 import contextfunction
@contextfunction
def ts_no_tz(context):
return context['execution_date'].strftime("%Y-%m-%dT%H:%M:%S")
dag = DAG(
# ...
user_defined_macros = { 'ts_no_tz': ts_no_tz }
)
with dag:
task = BashOperator(task_id='test', bash_command='echo {{ts}} {{
ts_no_tz() }}')
{code}
(It has to be a function call in the template, so not quite as straight forward)
> Old airflow ->{{ ts }} format 2019-02-19T10:00:00 and new->
> 2019-02-19T17:00:00+00:00
> -------------------------------------------------------------------------------------
>
> Key: AIRFLOW-3928
> URL: https://issues.apache.org/jira/browse/AIRFLOW-3928
> Project: Apache Airflow
> Issue Type: Improvement
> Reporter: Shubham Gupta
> Priority: Major
>
> Hello, I have seen this format change of {{ ts }} which is quite irritating
> as now I have to do code changes in all my files. Do you provide any
> alternative which I can use in place of {{ ts }}, so that I get
> 2019-02-19T10:00:00 format instead of 2019-02-19T17:00:00+00:00.
> Thanks!
> Regards,
> Shubhm Gupta
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)