You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by pi...@apache.org on 2025/09/01 13:35:58 UTC
(airflow) branch v3-0-test updated: [v3-0-test] Fix timezone conversion in datetime trigger parameters (#54593) (#55141)
This is an automated email from the ASF dual-hosted git repository.
pierrejeambrun pushed a commit to branch v3-0-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/v3-0-test by this push:
new ea94dba8cbf [v3-0-test] Fix timezone conversion in datetime trigger parameters (#54593) (#55141)
ea94dba8cbf is described below
commit ea94dba8cbf777adc994bf3fd191b30f43f9040f
Author: github-actions[bot] <41...@users.noreply.github.com>
AuthorDate: Mon Sep 1 15:35:50 2025 +0200
[v3-0-test] Fix timezone conversion in datetime trigger parameters (#54593) (#55141)
* onChange utc conversio bug
* isValid
* lint
* revert & workaround
* fix cmt lint
* add back support for sec/ms
---------
(cherry picked from commit dd9981531248625ddf187c71b0705794de7a42c8)
Co-authored-by: Steve Ahn <st...@g.ucla.edu>
Co-authored-by: AhnSteve <st...@blizzard.com>
---
.../src/airflow/ui/src/components/DateTimeInput.tsx | 10 ++++++----
.../ui/src/components/FlexibleForm/FieldDateTime.tsx | 14 ++++----------
2 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/airflow-core/src/airflow/ui/src/components/DateTimeInput.tsx b/airflow-core/src/airflow/ui/src/components/DateTimeInput.tsx
index 48c7a41099e..d31257a3623 100644
--- a/airflow-core/src/airflow/ui/src/components/DateTimeInput.tsx
+++ b/airflow-core/src/airflow/ui/src/components/DateTimeInput.tsx
@@ -32,8 +32,11 @@ type Props = {
export const DateTimeInput = forwardRef<HTMLInputElement, Props>(({ onChange, value, ...rest }, ref) => {
const { selectedTimezone } = useTimezone();
- // Make the value timezone-aware
- const date = dayjs(value).tz(selectedTimezone).format("YYYY-MM-DDTHH:mm:ss.SSS");
+ // Convert UTC value to local time for display
+ const displayValue =
+ Boolean(value) && dayjs(value).isValid()
+ ? dayjs(value).tz(selectedTimezone).format("YYYY-MM-DDTHH:mm:ss.SSS")
+ : "";
return (
<Input
@@ -42,7 +45,6 @@ export const DateTimeInput = forwardRef<HTMLInputElement, Props>(({ onChange, va
...event,
target: {
...event.target,
- // Return a timezone-aware ISO string
value: dayjs(event.target.value).isValid()
? dayjs(event.target.value).tz(selectedTimezone, true).toISOString()
: "",
@@ -51,7 +53,7 @@ export const DateTimeInput = forwardRef<HTMLInputElement, Props>(({ onChange, va
}
ref={ref}
type="datetime-local"
- value={date}
+ value={displayValue}
{...rest}
/>
);
diff --git a/airflow-core/src/airflow/ui/src/components/FlexibleForm/FieldDateTime.tsx b/airflow-core/src/airflow/ui/src/components/FlexibleForm/FieldDateTime.tsx
index cc8d23184b3..bee5507e970 100644
--- a/airflow-core/src/airflow/ui/src/components/FlexibleForm/FieldDateTime.tsx
+++ b/airflow-core/src/airflow/ui/src/components/FlexibleForm/FieldDateTime.tsx
@@ -27,16 +27,10 @@ export const FieldDateTime = ({ name, onUpdate, ...rest }: FlexibleFormElementPr
const { paramsDict, setParamsDict } = useParamStore();
const param = paramsDict[name] ?? paramPlaceholder;
const handleChange = (value: string) => {
+ // "undefined" values are removed from params, so we set it to null to avoid falling back to DAG defaults.
if (paramsDict[name]) {
- if (rest.type === "datetime-local") {
- // "undefined" values are removed from params, so we set it to null to avoid falling back to DAG defaults.
- // eslint-disable-next-line unicorn/no-null
- paramsDict[name].value = value === "" ? null : `${value}:00+00:00`; // Need to suffix to make it UTC like
- } else {
- // "undefined" values are removed from params, so we set it to null to avoid falling back to DAG defaults.
- // eslint-disable-next-line unicorn/no-null
- paramsDict[name].value = value === "" ? null : value;
- }
+ // eslint-disable-next-line unicorn/no-null
+ paramsDict[name].value = value === "" ? null : value;
}
setParamsDict(paramsDict);
@@ -50,7 +44,7 @@ export const FieldDateTime = ({ name, onUpdate, ...rest }: FlexibleFormElementPr
name={`element_${name}`}
onChange={(event) => handleChange(event.target.value)}
size="sm"
- value={((param.value ?? "") as string).slice(0, 16)}
+ value={(param.value as string) || ""}
/>
);
}