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

Function formatDate

apps/sim/app/workspace/[workspaceId]/logs/utils.ts:205–245  ·  view source on GitHub ↗
(dateString: string)

Source from the content-addressed store, hash-verified

203}
204
205export const formatDate = (dateString: string) => {
206 const date = new Date(dateString)
207 return {
208 full: date.toLocaleDateString('en-US', {
209 month: 'short',
210 day: 'numeric',
211 year: 'numeric',
212 hour: '2-digit',
213 minute: '2-digit',
214 second: '2-digit',
215 hour12: false,
216 }),
217 time: date.toLocaleTimeString([], {
218 hour: '2-digit',
219 minute: '2-digit',
220 second: '2-digit',
221 hour12: false,
222 }),
223 formatted: format(date, 'HH:mm:ss'),
224 compact: format(date, 'MMM d HH:mm:ss'),
225 compactDate: format(date, 'MMM d').toUpperCase(),
226 compactTime: format(date, 'h:mm a'),
227 relative: (() => {
228 const now = new Date()
229 const diffMs = now.getTime() - date.getTime()
230 const diffMins = Math.floor(diffMs / 60000)
231
232 if (diffMins < 1) return 'just now'
233 if (diffMins < 60) return `${diffMins}m ago`
234
235 const diffHours = Math.floor(diffMins / 60)
236 if (diffHours < 24) return `${diffHours}h ago`
237
238 const diffDays = Math.floor(diffHours / 24)
239 if (diffDays === 1) return 'yesterday'
240 if (diffDays < 7) return `${diffDays}d ago`
241
242 return format(date, 'MMM d')
243 })(),
244 }
245}
246
247/**
248 * Extracts the original workflow input from a log entry for retry.

Callers 5

LogsFunction · 0.90
LogDetailsContentFunction · 0.90
getCompactDateLabelFunction · 0.90
EnrichmentDetailsContentFunction · 0.90
useAvailableResourcesFunction · 0.90

Calls 1

formatFunction · 0.85

Tested by

no test coverage detected