Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(scheduler): run a scheduled task once at a specific date and time #28104

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 15 commits intomain fromrefs/pull/28104/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Showing 21 changed files with 95 additions and 2 deletions (loading 18).

x
0 of 21 viewed, 21 left
83 additions and 1 deletionapps/mobile/src/features/settings/SettingsScheduledTasksRouteScreen.tsxModified
View file
@@ -109,6 +109,10 @@
​
function describeSchedule(task: ScheduledTask): string {
if (task.schedule.type === "webhook") return "On webhook";
+ if (task.schedule.type === "once") {
+ const runAt = new Date(task.schedule.runAt);
+ return `Once, ${formatRunAtDate(runAt)} at ${formatRunAtTime(runAt)}`;
+ }
if (task.schedule.type === "interval") return formatScheduledTaskInterval(task.schedule.everyMs);
const days = task.schedule.weekdays?.length ? repeatLabel(task.schedule.weekdays) : "Every day";
return `${days} at ${formatTime(task.schedule.timeOfDay)}`;
@@ -122,6 +126,14 @@
return time.toLocaleTimeString([], { hour: "numeric", minute: "2-digit" });
​
+function formatRunAtDate(value: Date): string {
+ return value.toLocaleDateString([], { month: "short", day: "numeric", year: "numeric" });
+}
+​
+function formatRunAtTime(value: Date): string {
+ return value.toLocaleTimeString([], { hour: "numeric", minute: "2-digit" });
+}
+​
function timePickerValue(value: string): Date {
const [hours, minutes] = value.split(":").map(Number);
const time = new Date();
@@ -687,6 +699,7 @@
});