ecerulm commented on a change in pull request #16678:
URL: https://github.com/apache/airflow/pull/16678#discussion_r660079266



##########
File path: airflow/models/dag.py
##########
@@ -422,6 +428,38 @@ def __exit__(self, _type, _value, _tb):
 
     # /Context Manager ----------------------------------------------
 
+    def _get_tzname_or_offset(self, obj):
+        if self._is_valid_pendulum_tz_id(obj):
+            return obj
+        if hasattr(obj, 'name'):
+            candidate = obj.name
+            if self._is_valid_pendulum_tz_id(candidate):
+                return candidate
+        try:
+            candidate = obj.tzname(datetime.now(timezone.utc))
+            if self._is_valid_pendulum_tz_id(candidate):
+                return candidate
+        except (NotImplementedError, ValueError):
+            pass
+
+        try:
+            candidate = 
int(obj.utcoffset(datetime.now(timezone.utc)).total_seconds())
+            if self._is_valid_pendulum_tz_id(candidate):
+                return candidate
+        except (NotImplementedError, ValueError):
+            pass
+
+        raise ValueError(f"Can't get a timezone name or offset from {obj}")
+
+    def _is_valid_pendulum_tz_id(self, id):

Review comment:
       ok renamed it to `is_valid_pendulum_tzname` and `name`




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to