uranusjr commented on code in PR #62709:
URL: https://github.com/apache/airflow/pull/62709#discussion_r3008391628
##########
airflow-core/src/airflow/partition_mappers/temporal.py:
##########
@@ -30,14 +34,21 @@ class _BaseTemporalMapper(PartitionMapper, ABC):
def __init__(
self,
+ *,
+ timezone: str | Timezone | FixedTimezone = "UTC",
input_format: str = "%Y-%m-%dT%H:%M:%S",
output_format: str | None = None,
):
self.input_format = input_format
self.output_format = output_format or self.default_output_format
+ if isinstance(timezone, str):
+ timezone = parse_timezone(timezone)
+ self._timezone = timezone
def to_downstream(self, key: str) -> str:
dt = datetime.strptime(key, self.input_format)
+ if dt.tzinfo is None:
+ dt = make_aware(dt, self._timezone)
Review Comment:
If `dt` has a different timezone to `self._timezone` (I think technically
possible with a custom `input_format`?) should we also convert `dt` to the
user-specified timezone? This may cause different time strings (and even dates
in edge cases).
--
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]