MCPcopy Create free account
hub / github.com/simstudioai/sim / formatEventTime

Function formatEventTime

apps/sim/connectors/google-calendar/google-calendar.ts:51–76  ·  view source on GitHub ↗

* Formats a CalendarEventTime into a human-readable string. * All-day events use the date field; timed events use dateTime.

(eventTime?: CalendarEventTime)

Source from the content-addressed store, hash-verified

49 * All-day events use the date field; timed events use dateTime.
50 */
51function formatEventTime(eventTime?: CalendarEventTime): string {
52 if (!eventTime) return 'Unknown'
53 if (eventTime.dateTime) {
54 const date = new Date(eventTime.dateTime)
55 return date.toLocaleString('en-US', {
56 weekday: 'long',
57 year: 'numeric',
58 month: 'long',
59 day: 'numeric',
60 hour: 'numeric',
61 minute: '2-digit',
62 timeZoneName: 'short',
63 timeZone: eventTime.timeZone || undefined,
64 })
65 }
66 if (eventTime.date) {
67 const date = new Date(`${eventTime.date}T00:00:00`)
68 return date.toLocaleDateString('en-US', {
69 weekday: 'long',
70 year: 'numeric',
71 month: 'long',
72 day: 'numeric',
73 })
74 }
75 return 'Unknown'
76}
77
78/**
79 * Determines whether the event is all-day based on whether `date` (not `dateTime`) is used.

Callers 1

eventToContentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected