{"version":3,"file":"_isFormatDateTime.mjs","names":[],"sources":["../../src/internal/_isFormatDateTime.ts"],"sourcesContent":["import { _isFormatDate } from \"./_isFormatDate\";\n\n/**\n * Checks timestamp syntax, calendar dates and possible UTC leap-second\n * position.\n *\n * An explicit Z or numeric offset is required. A second of 60 is permitted only\n * at a UTC June or December month-end boundary; this does not consult a\n * historical leap-second announcement table.\n *\n * @evidence contracts/common.md#principled-implementation The syntax expression bounds clock and offset fields and delegates the date to the calendar predicate. UTC setters preserve literal years, and offset subtraction determines whether a potential leap second occupies the permitted month-end minute.\n * @evidence contracts/common.md#clear-and-simple-design Ordinary seconds finish after syntax/calendar validation; only the leap-second branch constructs the UTC instant needed for the boundary decision.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts UTC conversion and the potential leap-second boundary are uniform rules. The implementation neither relies on local timezone nor special-cases fixture dates; historical announcements are outside this check.\n * @evidence contracts/common.md#meaningful-documentation The doc states that an offset is required, when a second of 60 is allowed and that no leap-second announcement table is consulted.\n */\nexport const _isFormatDateTime = (str: string): boolean => {\n  const match: RegExpExecArray | null = PATTERN.exec(str);\n  if (match === null || _isFormatDate(match[1]!) === false) return false;\n  if (match[7] !== \"60\") return true;\n\n  const instant: Date = new Date(0);\n  instant.setUTCFullYear(\n    Number(match[2]),\n    Number(match[3]) - 1,\n    Number(match[4]),\n  );\n  instant.setUTCHours(Number(match[5]), Number(match[6]), 0, 0);\n  const offset: number =\n    match[8] === undefined\n      ? 0\n      : (match[8] === \"+\" ? 1 : -1) *\n        (Number(match[9]) * 60 + Number(match[10]));\n  instant.setUTCMinutes(instant.getUTCMinutes() - offset);\n  return (\n    instant.getUTCHours() === 23 &&\n    instant.getUTCMinutes() === 59 &&\n    ((instant.getUTCMonth() === 5 && instant.getUTCDate() === 30) ||\n      (instant.getUTCMonth() === 11 && instant.getUTCDate() === 31))\n  );\n};\n\nconst PATTERN =\n  /^(([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01]))[Tt]((?:[01][0-9]|2[0-3])):([0-5][0-9]):([0-5][0-9]|60)(?:\\.[0-9]+)?(?:[Zz]|([+-])((?:[01][0-9]|2[0-3])):([0-5][0-9]))$/;\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAa,qBAAqB,QAAyB;CACzD,MAAM,QAAgC,QAAQ,KAAK,GAAG;CACtD,IAAI,UAAU,QAAQ,cAAc,MAAM,EAAG,MAAM,OAAO,OAAO;CACjE,IAAI,MAAM,OAAO,MAAM,OAAO;CAE9B,MAAM,0BAAgB,IAAI,KAAK,CAAC;CAChC,QAAQ,eACN,OAAO,MAAM,EAAE,GACf,OAAO,MAAM,EAAE,IAAI,GACnB,OAAO,MAAM,EAAE,CACjB;CACA,QAAQ,YAAY,OAAO,MAAM,EAAE,GAAG,OAAO,MAAM,EAAE,GAAG,GAAG,CAAC;CAC5D,MAAM,SACJ,MAAM,OAAO,KAAA,IACT,KACC,MAAM,OAAO,MAAM,IAAI,OACvB,OAAO,MAAM,EAAE,IAAI,KAAK,OAAO,MAAM,GAAG;CAC/C,QAAQ,cAAc,QAAQ,cAAc,IAAI,MAAM;CACtD,OACE,QAAQ,YAAY,MAAM,MAC1B,QAAQ,cAAc,MAAM,OAC1B,QAAQ,YAAY,MAAM,KAAK,QAAQ,WAAW,MAAM,MACvD,QAAQ,YAAY,MAAM,MAAM,QAAQ,WAAW,MAAM;AAEhE;AAEA,MAAM,UACJ"}