Mnovich/temporal foreground tasks (#2895)
Co-authored-by: Carlos M. Lopez <carlopez@squareup.com>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
export const formatToLocalDateTime = (dateString?: string | null): string => {
|
||||
if (!dateString) {
|
||||
return 'N/A';
|
||||
}
|
||||
try {
|
||||
const date = new Date(dateString);
|
||||
// Check if the date is valid
|
||||
if (isNaN(date.getTime())) {
|
||||
return 'Invalid Date';
|
||||
}
|
||||
return date.toLocaleString(); // Uses user's locale and timezone
|
||||
} catch (e) {
|
||||
console.error('Error formatting date:', e);
|
||||
return 'Invalid Date';
|
||||
}
|
||||
};
|
||||
|
||||
export const formatToLocalDateWithTimezone = (dateString?: string | null): string => {
|
||||
if (!dateString) {
|
||||
return 'N/A';
|
||||
}
|
||||
try {
|
||||
const date = new Date(dateString);
|
||||
if (isNaN(date.getTime())) {
|
||||
return 'Invalid Date';
|
||||
}
|
||||
// Format: Jan 1, 2023, 10:00:00 AM PST (example)
|
||||
return date.toLocaleString(undefined, {
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
hour: 'numeric',
|
||||
minute: '2-digit',
|
||||
second: '2-digit',
|
||||
timeZoneName: 'short',
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('Error formatting date with timezone:', e);
|
||||
return 'Invalid Date';
|
||||
}
|
||||
};
|
||||
@@ -8,10 +8,13 @@ export interface EnvToggles {
|
||||
GOOSE_SERVER__COMPUTER_CONTROLLER: boolean;
|
||||
}
|
||||
|
||||
export type SchedulingEngine = 'builtin-cron' | 'temporal';
|
||||
|
||||
export interface Settings {
|
||||
envToggles: EnvToggles;
|
||||
showMenuBarIcon: boolean;
|
||||
showDockIcon: boolean;
|
||||
schedulingEngine: SchedulingEngine;
|
||||
showQuitConfirmation: boolean;
|
||||
}
|
||||
|
||||
@@ -25,6 +28,7 @@ const defaultSettings: Settings = {
|
||||
},
|
||||
showMenuBarIcon: true,
|
||||
showDockIcon: true,
|
||||
schedulingEngine: 'builtin-cron',
|
||||
showQuitConfirmation: true,
|
||||
};
|
||||
|
||||
@@ -64,6 +68,15 @@ export function updateEnvironmentVariables(envToggles: EnvToggles): void {
|
||||
}
|
||||
}
|
||||
|
||||
export function updateSchedulingEngineEnvironment(schedulingEngine: SchedulingEngine): void {
|
||||
// Set GOOSE_SCHEDULER_TYPE based on the scheduling engine setting
|
||||
if (schedulingEngine === 'temporal') {
|
||||
process.env.GOOSE_SCHEDULER_TYPE = 'temporal';
|
||||
} else {
|
||||
process.env.GOOSE_SCHEDULER_TYPE = 'legacy';
|
||||
}
|
||||
}
|
||||
|
||||
// Menu management
|
||||
export function createEnvironmentMenu(
|
||||
envToggles: EnvToggles,
|
||||
|
||||
Reference in New Issue
Block a user