You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/06/29 12:53:01 UTC

[GitHub] [airflow] uranusjr commented on a diff in pull request #24724: Added Support in ts_nodash

uranusjr commented on code in PR #24724:
URL: https://github.com/apache/airflow/pull/24724#discussion_r909593111


##########
airflow/templates.py:
##########
@@ -56,9 +56,11 @@ def ts_filter(value):
     return value.isoformat()
 
 
-def ts_nodash_filter(value):
-    return value.strftime('%Y%m%dT%H%M%S')
-
+def ts_nodash_filter(*value):
+    if value:
+      return value.strftime('%Y%m%dT%H%M%S')
+    else:
+      return None

Review Comment:
   This is wrong since
   
   1. `datetime(0, 0, 0)` is falsy.
   2. The `*` should not exist.
   
   Something like this should be implemented instead
   
   ```python
   def ts_nodash_filter(value):
       if value is None:
           return None
       return value.strftime('%Y%m%dT%H%M%S')
   ```
   
   Also please add the same logic to `ds_filter`, `ds_nodash_filter`, `ts_filter`, and `ts_nodash_with_tz_filter` as well.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org