Automerge backed Markdown editor for the Atmosphere
Something went wrong. Try again.
1234567891011121314151617export function isStrictDate(value: unknown): value is string { if (typeof value !== 'string') return false const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value) if (!match) return false const date = new Date(`${value}T00:00:00.000Z`) return date.getUTCFullYear() === +match[1]! && date.getUTCMonth() + 1 === +match[2]! && date.getUTCDate() === +match[3]!}
export function isValidDateTime(value: unknown): value is string { if (typeof value !== 'string') return false const match = /^(\d{4}-\d{2}-\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?(Z|[+-](\d{2}):(\d{2}))$/.exec(value) if (!match || !isStrictDate(match[1])) return false if (+match[2]! > 23 || +match[3]! > 59 || +(match[4] ?? 0) > 59) return false if (match[7] && (+match[7] > 23 || +match[8]! > 59)) return false return Number.isFinite(Date.parse(value))}