diff --git a/frontend/src/pages/Pipelines/Components/Drawers/SchedulerDrawer/CronTab.jsx b/frontend/src/pages/Pipelines/Components/Drawers/SchedulerDrawer/CronTab.jsx
index 6680b7349..de6bc28ab 100644
--- a/frontend/src/pages/Pipelines/Components/Drawers/SchedulerDrawer/CronTab.jsx
+++ b/frontend/src/pages/Pipelines/Components/Drawers/SchedulerDrawer/CronTab.jsx
@@ -14,12 +14,15 @@ export function CronTab({ setValidationError, scheduleStatement, setScheduleStat
const MeData = useGlobalMeState();
const userTimezone = MeData.timezone.get();
+
// Set schedule for upcoming runs on cron expression change
useEffect(() => {
// Prepare schedule table
const sched = later.parse.cron(scheduleStatement);
+ sched.useLocalTime = false;
setSchedule(later.schedule(sched).next(20));
+
// Validation check on save
isValidCron(scheduleStatement) ? setValidationError(false) : setValidationError(true);
@@ -37,12 +40,12 @@ export function CronTab({ setValidationError, scheduleStatement, setScheduleStat
-
- {cronString.replace(/AM|PM/, (x) => x + ' UTC')}
-
+ {/*
+ {cronZone(cronString, schedule[0], timezone)}
+ */}
- {cronZone(cronString, schedule[0], timezone)}
+ {cronString.replace(/AM|PM/, (x) => x + " "+timezone)}
@@ -89,23 +92,23 @@ export function CronTab({ setValidationError, scheduleStatement, setScheduleStat
- {DateTime.fromJSDate(row, { zone: timezone }).toFormat('yyyy')}
+ HO {DateTime.fromJSDate(row, { zone: timezone }).toFormat('yyyy')}
{userTimezone ? (
-
+
- {DateTime.fromJSDate(row, { zone: timezone }).toFormat('HH:mm:ss')}
+ {DateTime.fromJSDate(row, { zone: "UTC" }).toFormat('HH:mm:ss')}
-
+
) : null}
{userTimezone ? (
-
+
- {DateTime.fromJSDate(row, { zone: timezone }).toFormat('z (ZZZZ)')}
+ {DateTime.fromJSDate(row, { zone: timezone }).toFormat('z (ZZZZ)')}
-
+
) : null}
);
@@ -141,16 +144,16 @@ export function CronTab({ setValidationError, scheduleStatement, setScheduleStat
Every 6 hours
setScheduleStatement('0 8 * * *')}>
- Every day at 8am (UTC)
+ Every day at 8am ({timezone})
setScheduleStatement('0 11 * * 5')}>
- Every Friday at 11am (UTC)
+ Every Friday at 11am ({timezone})
setScheduleStatement('0 22 * * 1-5')}>
- At 10pm, Monday through Friday (UTC)
+ At 10pm, Monday through Friday ({timezone})
setScheduleStatement('0 14 5 * *')}>
- Every month on day 5 at 2pm (UTC)
+ Every month on day 5 at 2pm ({timezone})
@@ -158,11 +161,15 @@ export function CronTab({ setValidationError, scheduleStatement, setScheduleStat
}
// Utility functions
-function cronZone(statement, next, zone) {
- // Return if there is no time
- if (/\d\d:\d\d (AM|PM)/.test(statement) === false) return;
-
- const time = DateTime.fromJSDate(next, { zone }).toFormat('hh:mm a z');
- statement = statement.replace(/\d\d:\d\d (AM|PM)/, time);
- return statement;
-}
+// function cronZone(statement, next, zone) {
+// // Return if there is no time
+// if (/\d\d:\d\d (AM|PM)/.test(statement) === false) return;
+
+// // Convert to timezone given, next is the parsed cron statement.
+// // {zone}
+// const time = DateTime.fromJSDate(next, "UTC" ).toFormat('hh:mm a z');
+// statement = statement.replace(/\d\d:\d\d (AM|PM)/, time);
+
+// console.log("Converted cron statement to user's timezone", next, statement, zone, time)
+// return statement;
+// }
diff --git a/frontend/src/pages/Pipelines/Components/Drawers/SchedulerDrawer/index.jsx b/frontend/src/pages/Pipelines/Components/Drawers/SchedulerDrawer/index.jsx
index caeebc1f9..b41cc28f8 100644
--- a/frontend/src/pages/Pipelines/Components/Drawers/SchedulerDrawer/index.jsx
+++ b/frontend/src/pages/Pipelines/Components/Drawers/SchedulerDrawer/index.jsx
@@ -23,11 +23,13 @@ const ScheduleDrawer = ({ handleClose, setElements }) => {
setTabValue(newValue);
};
- // Schedule state
+ // Schedule state
+ // scheduleStatement is the cron input.
const [scheduleStatement, setScheduleStatement] = useState('');
const [timezone, setTimezone] = useState(null);
const [seconds, setSeconds] = useState(null);
+
// Set triggerOnline switch on load
useEffect(() => {
setIsOnline(FlowState.selectedElement?.data?.triggerOnline.get());
diff --git a/frontend/src/pages/Pipelines/Components/Drawers/SchedulerDrawerRunPage/CronTab.jsx b/frontend/src/pages/Pipelines/Components/Drawers/SchedulerDrawerRunPage/CronTab.jsx
index 6680b7349..4a6d2f2ae 100644
--- a/frontend/src/pages/Pipelines/Components/Drawers/SchedulerDrawerRunPage/CronTab.jsx
+++ b/frontend/src/pages/Pipelines/Components/Drawers/SchedulerDrawerRunPage/CronTab.jsx
@@ -38,12 +38,12 @@ export function CronTab({ setValidationError, scheduleStatement, setScheduleStat
- {cronString.replace(/AM|PM/, (x) => x + ' UTC')}
+ {cronString.replace(/AM|PM/, (x) => x + ' ' + timezone)}
-
+ {/*
{cronZone(cronString, schedule[0], timezone)}
-
+ */}
Expected next 20 occurrences
@@ -93,19 +93,19 @@ export function CronTab({ setValidationError, scheduleStatement, setScheduleStat
{userTimezone ? (
-
+
- {DateTime.fromJSDate(row, { zone: timezone }).toFormat('HH:mm:ss')}
+ {DateTime.fromJSDate(row, { zone: "UTC" }).toFormat('HH:mm:ss')}
-
+
) : null}
{userTimezone ? (
-
+
{DateTime.fromJSDate(row, { zone: timezone }).toFormat('z (ZZZZ)')}
-
+
) : null}
);
@@ -141,16 +141,16 @@ export function CronTab({ setValidationError, scheduleStatement, setScheduleStat
Every 6 hours
setScheduleStatement('0 8 * * *')}>
- Every day at 8am (UTC)
+ Every day at 8am ({timezone})
setScheduleStatement('0 11 * * 5')}>
- Every Friday at 11am (UTC)
+ Every Friday at 11am ({timezone})
setScheduleStatement('0 22 * * 1-5')}>
- At 10pm, Monday through Friday (UTC)
+ At 10pm, Monday through Friday ({timezone})
setScheduleStatement('0 14 5 * *')}>
- Every month on day 5 at 2pm (UTC)
+ Every month on day 5 at 2pm ({timezone})
@@ -158,11 +158,11 @@ export function CronTab({ setValidationError, scheduleStatement, setScheduleStat
}
// Utility functions
-function cronZone(statement, next, zone) {
- // Return if there is no time
- if (/\d\d:\d\d (AM|PM)/.test(statement) === false) return;
-
- const time = DateTime.fromJSDate(next, { zone }).toFormat('hh:mm a z');
- statement = statement.replace(/\d\d:\d\d (AM|PM)/, time);
- return statement;
-}
+// function cronZone(statement, next, zone) {
+// // Return if there is no time
+// if (/\d\d:\d\d (AM|PM)/.test(statement) === false) return;
+
+// const time = DateTime.fromJSDate(next, { zone }).toFormat('hh:mm a z');
+// statement = statement.replace(/\d\d:\d\d (AM|PM)/, time);
+// return statement;
+// }
diff --git a/frontend/src/utils/cronZone.js b/frontend/src/utils/cronZone.js
index 84a11f82a..f5526dff1 100644
--- a/frontend/src/utils/cronZone.js
+++ b/frontend/src/utils/cronZone.js
@@ -25,8 +25,11 @@ export default function cronZone(cronStatement, zone, type) {
// Return if there is no time
if (/\d\d:\d\d (AM|PM)/.test(dateString) === false) return dateString;
- const next = later.schedule(later.parse.cron(cronStatement)).next(1);
- const time = DateTime.fromJSDate(next, { zone }).toFormat('HH:mm a');
- dateString = dateString.replace(/\d\d:\d\d (AM|PM)/, time);
+ const sched = later.parse.cron(cronStatement)
+
+ const next = later.schedule(sched).next(1);
+ // const time = DateTime.fromJSDate(next, { zone }).toFormat('HH:mm a');
+ dateString.replace(/AM|PM/, (x) => x + ' ' + zone)
+ // dateString = dateString.replace(/\d\d:\d\d (AM|PM)/, time);
return dateString;
}