MCPcopy
hub / github.com/simstudioai/sim / zonedWallClock

Function zonedWallClock

apps/sim/lib/core/utils/timezone.ts:90–102  ·  view source on GitHub ↗
(instant: Date, timeZone: string)

Source from the content-addressed store, hash-verified

88 * to recover the local date/time a stored task instant represents in its zone.
89 */
90export function zonedWallClock(instant: Date, timeZone: string): string {
91 const parts = new Intl.DateTimeFormat('en-CA', {
92 timeZone,
93 year: 'numeric',
94 month: '2-digit',
95 day: '2-digit',
96 hour: '2-digit',
97 minute: '2-digit',
98 hourCycle: 'h23',
99 }).formatToParts(instant)
100 const get = (type: string) => parts.find((p) => p.type === type)?.value ?? '00'
101 return `${get('year')}-${get('month')}-${get('day')}T${get('hour')}:${get('minute')}`
102}
103
104/** The current wall-clock time in `timeZone` as a naive `yyyy-MM-ddTHH:mm` string. */
105export function wallClockNow(timeZone: string): string {

Callers 4

cronToRecurrenceFunction · 0.90
useScheduledTasksFunction · 0.90
wallClockNowFunction · 0.85
zonedClockDateFunction · 0.85

Calls 1

getFunction · 0.70

Tested by

no test coverage detected