@northguild/gmt 1.18.0 → 1.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -2920
- package/dist/calendar/calculate/bucketRange.d.ts +10 -2
- package/dist/calendar/calculate/bucketRange.js +18 -61
- package/dist/calendar/calculate/floorToZone.d.ts +10 -2
- package/dist/calendar/calculate/floorToZone.js +15 -7
- package/dist/calendar/hours/addOperatingTime.d.ts +6 -0
- package/dist/calendar/hours/addOperatingTime.js +7 -1
- package/dist/calendar/hours/isOpenAt.d.ts +6 -0
- package/dist/calendar/hours/isOpenAt.js +6 -0
- package/dist/calendar/hours/nextCloseAt.d.ts +6 -0
- package/dist/calendar/hours/nextCloseAt.js +7 -1
- package/dist/calendar/hours/nextOpenAt.d.ts +6 -0
- package/dist/calendar/hours/nextOpenAt.js +7 -1
- package/dist/calendar/hours/operatingIntervals.d.ts +5 -0
- package/dist/calendar/hours/operatingIntervals.js +5 -0
- package/dist/calendar/hours/operatingTimeBetween.d.ts +5 -0
- package/dist/calendar/hours/operatingTimeBetween.js +5 -0
- package/dist/calendar/hours/recurringWindows.d.ts +8 -1
- package/dist/calendar/hours/recurringWindows.js +12 -4
- package/dist/duration/calculate/durationFromUnits.d.ts +47 -0
- package/dist/duration/calculate/durationFromUnits.js +67 -0
- package/dist/duration/calculate/getDurationUnit.d.ts +2 -2
- package/dist/duration/calculate/getDurationUnit.js +2 -2
- package/dist/duration/calculate/index.d.ts +3 -1
- package/dist/duration/calculate/index.js +3 -1
- package/dist/duration/calculate/negateDuration.d.ts +1 -1
- package/dist/duration/calculate/negateDuration.js +1 -1
- package/dist/duration/calculate/{durationAs.d.ts → totalDuration.d.ts} +25 -19
- package/dist/duration/calculate/{durationAs.js → totalDuration.js} +25 -19
- package/dist/duration/calculate/totalUnits.d.ts +49 -0
- package/dist/duration/calculate/totalUnits.js +73 -0
- package/dist/duration/compare/compareDurations.d.ts +1 -1
- package/dist/duration/compare/compareDurations.js +1 -1
- package/dist/duty/calculate/dutyDayFor.d.ts +38 -0
- package/dist/duty/calculate/dutyDayFor.js +71 -0
- package/dist/duty/calculate/dutyTotals.d.ts +24 -0
- package/dist/duty/calculate/dutyTotals.js +41 -0
- package/dist/duty/calculate/dutyViolations.d.ts +74 -0
- package/dist/duty/calculate/dutyViolations.js +65 -0
- package/dist/duty/calculate/evaluateDutyLog.d.ts +77 -0
- package/dist/duty/calculate/evaluateDutyLog.js +75 -0
- package/dist/duty/calculate/index.d.ts +7 -0
- package/dist/duty/calculate/index.js +7 -0
- package/dist/duty/calculate/longestRun.d.ts +28 -0
- package/dist/duty/calculate/longestRun.js +54 -0
- package/dist/duty/calculate/qualifyingRestPairs.d.ts +37 -0
- package/dist/duty/calculate/qualifyingRestPairs.js +58 -0
- package/dist/duty/calculate/qualifyingRests.d.ts +27 -0
- package/dist/duty/calculate/qualifyingRests.js +49 -0
- package/dist/duty/index.d.ts +3 -0
- package/dist/duty/index.js +4 -0
- package/dist/duty/validate/index.d.ts +1 -0
- package/dist/duty/validate/index.js +1 -0
- package/dist/duty/validate/isValidDutyLog.d.ts +24 -0
- package/dist/duty/validate/isValidDutyLog.js +34 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/instant/convert/classifyLocal.d.ts +5 -1
- package/dist/instant/convert/classifyLocal.js +16 -6
- package/dist/instant/convert/fromOffsetInstant.d.ts +4 -0
- package/dist/instant/convert/fromOffsetInstant.js +6 -1
- package/dist/instant/convert/resolveLocal.d.ts +7 -2
- package/dist/instant/convert/resolveLocal.js +16 -8
- package/dist/instant/convert/toOffsetInstant.d.ts +12 -8
- package/dist/instant/convert/toOffsetInstant.js +19 -11
- package/dist/instant/index.d.ts +1 -0
- package/dist/instant/index.js +1 -0
- package/dist/instant/validate/index.d.ts +1 -0
- package/dist/instant/validate/index.js +1 -0
- package/dist/instant/validate/isValidUtcOffset.d.ts +32 -0
- package/dist/instant/validate/isValidUtcOffset.js +35 -0
- package/dist/intermodal/calculate/chargeableDays.d.ts +6 -0
- package/dist/intermodal/calculate/chargeableDays.js +12 -4
- package/dist/intermodal/calculate/freeTimeExpiry.d.ts +7 -0
- package/dist/intermodal/calculate/freeTimeExpiry.js +15 -4
- package/dist/intermodal/calculate/index.d.ts +1 -0
- package/dist/intermodal/calculate/index.js +1 -0
- package/dist/intermodal/calculate/multimodalETA.d.ts +76 -0
- package/dist/intermodal/calculate/multimodalETA.js +145 -0
- package/dist/intermodal/format/bolTimestamp.d.ts +76 -0
- package/dist/intermodal/format/bolTimestamp.js +78 -0
- package/dist/intermodal/format/formatEdifactDate.d.ts +34 -0
- package/dist/intermodal/format/formatEdifactDate.js +42 -0
- package/dist/intermodal/format/formatEdifactDatePeriod.d.ts +35 -0
- package/dist/intermodal/format/formatEdifactDatePeriod.js +43 -0
- package/dist/intermodal/format/formatEdifactDateTime.d.ts +37 -0
- package/dist/intermodal/format/formatEdifactDateTime.js +45 -0
- package/dist/intermodal/format/formatEdifactDateTimePeriod.d.ts +40 -0
- package/dist/intermodal/format/formatEdifactDateTimePeriod.js +48 -0
- package/dist/intermodal/format/formatEdifactOffsetDateTime.d.ts +62 -0
- package/dist/intermodal/format/formatEdifactOffsetDateTime.js +70 -0
- package/dist/intermodal/format/formatEdifactTime.d.ts +35 -0
- package/dist/intermodal/format/formatEdifactTime.js +43 -0
- package/dist/intermodal/format/formatEpcisEvent.d.ts +47 -0
- package/dist/intermodal/format/formatEpcisEvent.js +79 -0
- package/dist/intermodal/format/formatX12Date.d.ts +35 -0
- package/dist/intermodal/format/formatX12Date.js +43 -0
- package/dist/intermodal/format/formatX12DateRange.d.ts +37 -0
- package/dist/intermodal/format/formatX12DateRange.js +45 -0
- package/dist/intermodal/format/formatX12DateTime.d.ts +39 -0
- package/dist/intermodal/format/formatX12DateTime.js +47 -0
- package/dist/intermodal/format/formatX12DateTimeRange.d.ts +40 -0
- package/dist/intermodal/format/formatX12DateTimeRange.js +48 -0
- package/dist/intermodal/format/formatX12Time.d.ts +42 -0
- package/dist/intermodal/format/formatX12Time.js +50 -0
- package/dist/intermodal/format/formatX12TimeElement.d.ts +46 -0
- package/dist/intermodal/format/formatX12TimeElement.js +54 -0
- package/dist/intermodal/format/index.d.ts +14 -0
- package/dist/intermodal/format/index.js +14 -0
- package/dist/intermodal/index.d.ts +3 -0
- package/dist/intermodal/index.js +3 -0
- package/dist/intermodal/parse/classifyEdifactDtmFormat.d.ts +48 -0
- package/dist/intermodal/parse/classifyEdifactDtmFormat.js +55 -0
- package/dist/intermodal/parse/classifyX12DateTimePeriodFormat.d.ts +50 -0
- package/dist/intermodal/parse/classifyX12DateTimePeriodFormat.js +57 -0
- package/dist/intermodal/parse/classifyX12TimeCode.d.ts +46 -0
- package/dist/intermodal/parse/classifyX12TimeCode.js +57 -0
- package/dist/intermodal/parse/index.d.ts +18 -0
- package/dist/intermodal/parse/index.js +18 -0
- package/dist/intermodal/parse/parseEdifactDate.d.ts +37 -0
- package/dist/intermodal/parse/parseEdifactDate.js +45 -0
- package/dist/intermodal/parse/parseEdifactDatePeriod.d.ts +43 -0
- package/dist/intermodal/parse/parseEdifactDatePeriod.js +51 -0
- package/dist/intermodal/parse/parseEdifactDateTime.d.ts +43 -0
- package/dist/intermodal/parse/parseEdifactDateTime.js +51 -0
- package/dist/intermodal/parse/parseEdifactDateTimePeriod.d.ts +45 -0
- package/dist/intermodal/parse/parseEdifactDateTimePeriod.js +53 -0
- package/dist/intermodal/parse/parseEdifactOffsetDateTime.d.ts +60 -0
- package/dist/intermodal/parse/parseEdifactOffsetDateTime.js +68 -0
- package/dist/intermodal/parse/parseEdifactTime.d.ts +37 -0
- package/dist/intermodal/parse/parseEdifactTime.js +45 -0
- package/dist/intermodal/parse/parseEpcisEvent.d.ts +95 -0
- package/dist/intermodal/parse/parseEpcisEvent.js +102 -0
- package/dist/intermodal/parse/parseX12Date.d.ts +39 -0
- package/dist/intermodal/parse/parseX12Date.js +47 -0
- package/dist/intermodal/parse/parseX12DateAndTime.d.ts +52 -0
- package/dist/intermodal/parse/parseX12DateAndTime.js +61 -0
- package/dist/intermodal/parse/parseX12DateRange.d.ts +44 -0
- package/dist/intermodal/parse/parseX12DateRange.js +52 -0
- package/dist/intermodal/parse/parseX12DateTime.d.ts +45 -0
- package/dist/intermodal/parse/parseX12DateTime.js +53 -0
- package/dist/intermodal/parse/parseX12DateTimeRange.d.ts +46 -0
- package/dist/intermodal/parse/parseX12DateTimeRange.js +54 -0
- package/dist/intermodal/parse/parseX12Time.d.ts +65 -0
- package/dist/intermodal/parse/parseX12Time.js +77 -0
- package/dist/intermodal/parse/x12TimeCodeOffset.d.ts +57 -0
- package/dist/intermodal/parse/x12TimeCodeOffset.js +110 -0
- package/dist/intermodal/parse/x12TimeCodeZone.d.ts +57 -0
- package/dist/intermodal/parse/x12TimeCodeZone.js +105 -0
- package/dist/intermodal/validate/index.d.ts +18 -0
- package/dist/intermodal/validate/index.js +18 -0
- package/dist/intermodal/validate/isValidEdifactDate.d.ts +26 -0
- package/dist/intermodal/validate/isValidEdifactDate.js +28 -0
- package/dist/intermodal/validate/isValidEdifactDatePeriod.d.ts +28 -0
- package/dist/intermodal/validate/isValidEdifactDatePeriod.js +30 -0
- package/dist/intermodal/validate/isValidEdifactDateTime.d.ts +30 -0
- package/dist/intermodal/validate/isValidEdifactDateTime.js +32 -0
- package/dist/intermodal/validate/isValidEdifactDateTimePeriod.d.ts +28 -0
- package/dist/intermodal/validate/isValidEdifactDateTimePeriod.js +30 -0
- package/dist/intermodal/validate/isValidEdifactDtmFormat.d.ts +39 -0
- package/dist/intermodal/validate/isValidEdifactDtmFormat.js +42 -0
- package/dist/intermodal/validate/isValidEdifactOffsetDateTime.d.ts +36 -0
- package/dist/intermodal/validate/isValidEdifactOffsetDateTime.js +38 -0
- package/dist/intermodal/validate/isValidEdifactTime.d.ts +28 -0
- package/dist/intermodal/validate/isValidEdifactTime.js +30 -0
- package/dist/intermodal/validate/isValidEpcisEvent.d.ts +41 -0
- package/dist/intermodal/validate/isValidEpcisEvent.js +58 -0
- package/dist/intermodal/validate/isValidEpcisEventTime.d.ts +33 -0
- package/dist/intermodal/validate/isValidEpcisEventTime.js +48 -0
- package/dist/intermodal/validate/isValidEpcisTimeZoneOffset.d.ts +30 -0
- package/dist/intermodal/validate/isValidEpcisTimeZoneOffset.js +38 -0
- package/dist/intermodal/validate/isValidX12Date.d.ts +28 -0
- package/dist/intermodal/validate/isValidX12Date.js +30 -0
- package/dist/intermodal/validate/isValidX12DateAndTime.d.ts +32 -0
- package/dist/intermodal/validate/isValidX12DateAndTime.js +35 -0
- package/dist/intermodal/validate/isValidX12DateRange.d.ts +29 -0
- package/dist/intermodal/validate/isValidX12DateRange.js +31 -0
- package/dist/intermodal/validate/isValidX12DateTime.d.ts +30 -0
- package/dist/intermodal/validate/isValidX12DateTime.js +32 -0
- package/dist/intermodal/validate/isValidX12DateTimePeriodFormat.d.ts +43 -0
- package/dist/intermodal/validate/isValidX12DateTimePeriodFormat.js +46 -0
- package/dist/intermodal/validate/isValidX12DateTimeRange.d.ts +31 -0
- package/dist/intermodal/validate/isValidX12DateTimeRange.js +33 -0
- package/dist/intermodal/validate/isValidX12Time.d.ts +38 -0
- package/dist/intermodal/validate/isValidX12Time.js +40 -0
- package/dist/intermodal/validate/isValidX12TimeCode.d.ts +38 -0
- package/dist/intermodal/validate/isValidX12TimeCode.js +41 -0
- package/dist/internal/businessCalendar.js +4 -9
- package/dist/internal/dutyEngine.d.ts +125 -0
- package/dist/internal/dutyEngine.js +1746 -0
- package/dist/internal/dutyLog.d.ts +27 -0
- package/dist/internal/dutyLog.js +47 -0
- package/dist/internal/dutyPeriods.d.ts +135 -0
- package/dist/internal/dutyPeriods.js +369 -0
- package/dist/internal/dutyRules.d.ts +197 -0
- package/dist/internal/dutyRules.js +484 -0
- package/dist/internal/ediDateTimeFields.d.ts +97 -0
- package/dist/internal/ediDateTimeFields.js +288 -0
- package/dist/internal/ediDateTimeWriter.d.ts +92 -0
- package/dist/internal/ediDateTimeWriter.js +298 -0
- package/dist/internal/ediGrammar.d.ts +158 -0
- package/dist/internal/ediGrammar.js +384 -0
- package/dist/internal/englishCalendarNames.d.ts +3 -1
- package/dist/internal/englishCalendarNames.js +3 -1
- package/dist/internal/freeTimeLedger.d.ts +5 -0
- package/dist/internal/freeTimeLedger.js +11 -2
- package/dist/internal/index.d.ts +5 -2
- package/dist/internal/index.js +9 -2
- package/dist/internal/intervalNanoseconds.js +2 -1
- package/dist/internal/isObject.d.ts +13 -6
- package/dist/internal/isObject.js +14 -7
- package/dist/internal/isoYearString.d.ts +21 -0
- package/dist/internal/isoYearString.js +27 -0
- package/dist/internal/maxPieces.js +2 -1
- package/dist/internal/normalizeTimeZone.d.ts +4 -1
- package/dist/internal/normalizeTimeZone.js +4 -1
- package/dist/internal/operatingSchedule.d.ts +13 -4
- package/dist/internal/operatingSchedule.js +146 -58
- package/dist/internal/patternToken.d.ts +10 -3
- package/dist/internal/patternToken.js +31 -12
- package/dist/internal/readDurationUnits.d.ts +34 -0
- package/dist/internal/readDurationUnits.js +78 -0
- package/dist/internal/readSetFields.d.ts +50 -0
- package/dist/internal/readSetFields.js +179 -0
- package/dist/internal/resolveRelativeUnit.d.ts +1 -1
- package/dist/internal/resolveRelativeUnit.js +1 -1
- package/dist/internal/resolveUnixIntervalPair.d.ts +8 -2
- package/dist/internal/resolveUnixIntervalPair.js +11 -7
- package/dist/internal/startOrEndOfUnix.d.ts +2 -1
- package/dist/internal/startOrEndOfUnix.js +9 -6
- package/dist/internal/twoDigitYear.d.ts +19 -0
- package/dist/internal/twoDigitYear.js +22 -0
- package/dist/internal/unixEpochValue.js +3 -2
- package/dist/internal/unixWallClock.d.ts +24 -0
- package/dist/internal/unixWallClock.js +35 -0
- package/dist/internal/utcWallClock.d.ts +20 -0
- package/dist/internal/utcWallClock.js +32 -0
- package/dist/internal/yearWindowStart.d.ts +28 -0
- package/dist/internal/yearWindowStart.js +52 -0
- package/dist/internal/zoneBucketCap.d.ts +18 -0
- package/dist/internal/zoneBucketCap.js +64 -0
- package/dist/internal/zoneFrame.d.ts +180 -0
- package/dist/internal/zoneFrame.js +221 -0
- package/dist/internal/zonedNowUnitValue.d.ts +7 -4
- package/dist/internal/zonedNowUnitValue.js +8 -4
- package/dist/internal/zonedWallClockDifference.js +4 -4
- package/dist/internal/zonedWallClockOperations.d.ts +5 -2
- package/dist/internal/zonedWallClockOperations.js +7 -10
- package/dist/plain/calculate/addDate.js +4 -7
- package/dist/plain/calculate/addDateTime.js +4 -7
- package/dist/plain/calculate/addTime.js +4 -7
- package/dist/plain/calculate/endOfTime.d.ts +1 -1
- package/dist/plain/calculate/setDate.d.ts +20 -3
- package/dist/plain/calculate/setDate.js +27 -7
- package/dist/plain/calculate/setDateTime.d.ts +15 -3
- package/dist/plain/calculate/setDateTime.js +22 -7
- package/dist/plain/calculate/setTime.d.ts +13 -1
- package/dist/plain/calculate/setTime.js +21 -6
- package/dist/plain/calculate/startOfTime.d.ts +1 -1
- package/dist/plain/calculate/subtractDate.js +4 -7
- package/dist/plain/calculate/subtractDateTime.js +4 -7
- package/dist/plain/calculate/subtractTime.js +4 -7
- package/dist/plain/format/formatCalendar.js +2 -1
- package/dist/plain/format/formatRelativeDate.js +2 -1
- package/dist/plain/format/formatRelativeDateTime.js +2 -1
- package/dist/plain/format/formatRelativeTime.js +2 -1
- package/dist/plain/format/{formatSql.d.ts → formatSqlDateTime.d.ts} +7 -7
- package/dist/plain/format/{formatSql.js → formatSqlDateTime.js} +7 -7
- package/dist/plain/format/index.d.ts +1 -1
- package/dist/plain/format/index.js +1 -1
- package/dist/plain/get/getNowUnit.d.ts +2 -0
- package/dist/plain/get/getNowUnit.js +2 -0
- package/dist/plain/get/getYear.d.ts +2 -0
- package/dist/plain/get/getYear.js +4 -3
- package/dist/plain/interval/intervalXorAllDate.js +2 -2
- package/dist/plain/interval/intervalXorAllDateTime.js +2 -2
- package/dist/plain/interval/intervalXorAllTime.js +2 -2
- package/dist/plain/interval/mergeIntervalsDate.js +2 -2
- package/dist/plain/interval/mergeIntervalsDateTime.js +2 -2
- package/dist/plain/interval/mergeIntervalsTime.js +2 -2
- package/dist/plain/parse/index.d.ts +1 -1
- package/dist/plain/parse/index.js +1 -1
- package/dist/plain/parse/parseDateTimeWithPattern.d.ts +16 -3
- package/dist/plain/parse/parseDateTimeWithPattern.js +20 -5
- package/dist/plain/parse/parseDateWithPattern.d.ts +17 -3
- package/dist/plain/parse/parseDateWithPattern.js +21 -5
- package/dist/plain/parse/{parseSql.d.ts → parseSqlDateTime.d.ts} +8 -8
- package/dist/plain/parse/{parseSql.js → parseSqlDateTime.js} +8 -8
- package/dist/plain/parse/parseTimeWithPattern.js +1 -0
- package/dist/plain/parse/parseUnitFromDate.d.ts +3 -0
- package/dist/plain/parse/parseUnitFromDate.js +5 -1
- package/dist/plain/parse/parseUnitFromDateTime.d.ts +3 -0
- package/dist/plain/parse/parseUnitFromDateTime.js +5 -1
- package/dist/plain/parse/parseYearFromDate.d.ts +5 -2
- package/dist/plain/parse/parseYearFromDate.js +7 -3
- package/dist/plain/parse/parseYearFromDateTime.d.ts +4 -2
- package/dist/plain/parse/parseYearFromDateTime.js +6 -3
- package/dist/plain/validate/index.d.ts +1 -0
- package/dist/plain/validate/index.js +1 -0
- package/dist/plain/validate/isValidSqlDateTime.d.ts +33 -0
- package/dist/plain/validate/isValidSqlDateTime.js +36 -0
- package/dist/precision/convert/fromNanoseconds.d.ts +9 -3
- package/dist/precision/convert/fromNanoseconds.js +9 -3
- package/dist/regex/epcis.d.ts +60 -0
- package/dist/regex/epcis.js +60 -0
- package/dist/regex/http-date.d.ts +6 -4
- package/dist/regex/http-date.js +6 -4
- package/dist/regex/index.d.ts +1 -0
- package/dist/regex/index.js +1 -0
- package/dist/regex/rfc-2822.d.ts +2 -0
- package/dist/regex/rfc-2822.js +2 -0
- package/dist/regex/rfc-3339.d.ts +3 -1
- package/dist/regex/rfc-3339.js +3 -1
- package/dist/regex/sql-date-time.d.ts +2 -1
- package/dist/regex/sql-date-time.js +2 -1
- package/dist/regex/time-zone-like.d.ts +3 -2
- package/dist/regex/time-zone-like.js +3 -2
- package/dist/regex/utc-offset.d.ts +2 -1
- package/dist/regex/utc-offset.js +2 -1
- package/dist/transport/calculate/crossingTime.d.ts +6 -1
- package/dist/transport/calculate/crossingTime.js +6 -1
- package/dist/transport/calculate/cutoffAt.d.ts +6 -1
- package/dist/transport/calculate/cutoffAt.js +2 -0
- package/dist/transport/calculate/cutoffSchedule.d.ts +6 -1
- package/dist/transport/calculate/cutoffSchedule.js +2 -0
- package/dist/transport/calculate/dwellTime.d.ts +6 -1
- package/dist/transport/calculate/dwellTime.js +6 -1
- package/dist/transport/calculate/scheduleDelivery.d.ts +13 -5
- package/dist/transport/calculate/scheduleDelivery.js +6 -1
- package/dist/transport/convert/etaAtZone.d.ts +6 -1
- package/dist/transport/convert/etaAtZone.js +6 -1
- package/dist/types/business-calendar.d.ts +5 -4
- package/dist/types/duty.d.ts +777 -0
- package/dist/types/duty.js +0 -0
- package/dist/types/edi.d.ts +407 -0
- package/dist/types/edi.js +0 -0
- package/dist/types/epcis.d.ts +25 -0
- package/dist/types/epcis.js +0 -0
- package/dist/types/exact-duration-unit.d.ts +8 -0
- package/dist/types/exact-duration-unit.js +0 -0
- package/dist/types/free-time-options.d.ts +4 -3
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +5 -0
- package/dist/types/operating-schedule.d.ts +3 -2
- package/dist/types/two-digit-year.d.ts +23 -0
- package/dist/types/two-digit-year.js +0 -0
- package/dist/types/zone-bucket-unit.d.ts +1 -1
- package/dist/unix/calculate/addUnix.d.ts +11 -2
- package/dist/unix/calculate/addUnix.js +14 -11
- package/dist/unix/calculate/diffUnix.d.ts +10 -2
- package/dist/unix/calculate/diffUnix.js +11 -6
- package/dist/unix/calculate/diffUnixAsDuration.d.ts +10 -2
- package/dist/unix/calculate/diffUnixAsDuration.js +10 -5
- package/dist/unix/calculate/endOfQuarterForUnix.d.ts +10 -2
- package/dist/unix/calculate/endOfQuarterForUnix.js +6 -0
- package/dist/unix/calculate/endOfUnix.d.ts +11 -2
- package/dist/unix/calculate/endOfUnix.js +7 -0
- package/dist/unix/calculate/isBetweenUnix.d.ts +3 -2
- package/dist/unix/calculate/isBetweenUnix.js +3 -3
- package/dist/unix/calculate/roundUnix.d.ts +10 -2
- package/dist/unix/calculate/roundUnix.js +13 -6
- package/dist/unix/calculate/setUnix.d.ts +25 -5
- package/dist/unix/calculate/setUnix.js +33 -12
- package/dist/unix/calculate/startOfQuarterForUnix.d.ts +10 -2
- package/dist/unix/calculate/startOfQuarterForUnix.js +6 -0
- package/dist/unix/calculate/startOfUnix.d.ts +11 -2
- package/dist/unix/calculate/startOfUnix.js +7 -0
- package/dist/unix/calculate/subtractUnix.d.ts +10 -2
- package/dist/unix/calculate/subtractUnix.js +13 -11
- package/dist/unix/compare/areUnixEqualBy.d.ts +11 -2
- package/dist/unix/compare/areUnixEqualBy.js +7 -0
- package/dist/unix/convert/convertUnixToPlainDate.d.ts +5 -2
- package/dist/unix/convert/convertUnixToPlainDate.js +5 -4
- package/dist/unix/convert/convertUnixToPlainDateTime.d.ts +5 -2
- package/dist/unix/convert/convertUnixToPlainDateTime.js +5 -4
- package/dist/unix/convert/convertUnixToPlainTime.d.ts +5 -2
- package/dist/unix/convert/convertUnixToPlainTime.js +5 -4
- package/dist/unix/convert/convertUnixToZoned.d.ts +5 -1
- package/dist/unix/convert/convertUnixToZoned.js +5 -1
- package/dist/unix/format/formatCalendarUnix.d.ts +6 -2
- package/dist/unix/format/formatCalendarUnix.js +6 -1
- package/dist/unix/format/formatRelativeUnix.d.ts +11 -3
- package/dist/unix/format/formatRelativeUnix.js +13 -5
- package/dist/unix/format/formatUnix.d.ts +7 -2
- package/dist/unix/format/formatUnix.js +4 -0
- package/dist/unix/get/getUnixDay.d.ts +1 -3
- package/dist/unix/get/getUnixDay.js +5 -12
- package/dist/unix/get/getUnixHour.d.ts +1 -3
- package/dist/unix/get/getUnixHour.js +5 -12
- package/dist/unix/get/getUnixMicrosecond.d.ts +1 -3
- package/dist/unix/get/getUnixMicrosecond.js +4 -11
- package/dist/unix/get/getUnixMillisecond.d.ts +1 -3
- package/dist/unix/get/getUnixMillisecond.js +5 -12
- package/dist/unix/get/getUnixMinute.d.ts +1 -3
- package/dist/unix/get/getUnixMinute.js +5 -12
- package/dist/unix/get/getUnixMonth.d.ts +1 -3
- package/dist/unix/get/getUnixMonth.js +5 -12
- package/dist/unix/get/getUnixNanosecond.d.ts +1 -3
- package/dist/unix/get/getUnixNanosecond.js +4 -11
- package/dist/unix/get/getUnixNowUnit.d.ts +2 -0
- package/dist/unix/get/getUnixNowUnit.js +2 -0
- package/dist/unix/get/getUnixSecond.d.ts +1 -3
- package/dist/unix/get/getUnixSecond.js +5 -12
- package/dist/unix/get/getUnixYear.d.ts +3 -3
- package/dist/unix/get/getUnixYear.js +5 -12
- package/dist/unix/interval/intervalCountUnix.d.ts +11 -2
- package/dist/unix/interval/intervalCountUnix.js +7 -0
- package/dist/unix/interval/intervalFromDurationUnix.d.ts +10 -2
- package/dist/unix/interval/intervalFromDurationUnix.js +12 -7
- package/dist/unix/interval/intervalLengthUnix.d.ts +10 -2
- package/dist/unix/interval/intervalLengthUnix.js +6 -0
- package/dist/unix/interval/intervalOverlappingDaysUnix.d.ts +10 -2
- package/dist/unix/interval/intervalOverlappingDaysUnix.js +10 -5
- package/dist/unix/interval/splitIntervalByUnitUnix.d.ts +10 -2
- package/dist/unix/interval/splitIntervalByUnitUnix.js +12 -6
- package/dist/unix/parse/parseDateFromUnix.d.ts +4 -2
- package/dist/unix/parse/parseDateFromUnix.js +3 -3
- package/dist/unix/parse/parseDayFromUnix.d.ts +4 -2
- package/dist/unix/parse/parseDayOfWeekFromUnix.d.ts +4 -2
- package/dist/unix/parse/parseDayOfWeekFromUnix.js +2 -2
- package/dist/unix/parse/parseHourFromUnix.d.ts +4 -2
- package/dist/unix/parse/parseMicrosecondFromUnix.d.ts +4 -2
- package/dist/unix/parse/parseMillisecondFromUnix.d.ts +4 -2
- package/dist/unix/parse/parseMinuteFromUnix.d.ts +4 -2
- package/dist/unix/parse/parseMonthFromUnix.d.ts +4 -2
- package/dist/unix/parse/parseNanosecondFromUnix.d.ts +4 -2
- package/dist/unix/parse/parseSecondFromUnix.d.ts +4 -2
- package/dist/unix/parse/parseTimeFromUnix.d.ts +5 -2
- package/dist/unix/parse/parseTimeFromUnix.js +4 -3
- package/dist/unix/parse/parseUnitFromUnix.d.ts +9 -3
- package/dist/unix/parse/parseUnitFromUnix.js +21 -14
- package/dist/unix/parse/parseWeekFromUnix.d.ts +3 -2
- package/dist/unix/parse/parseWeekFromUnix.js +4 -4
- package/dist/unix/parse/parseYearFromUnix.d.ts +8 -3
- package/dist/unix/parse/parseYearFromUnix.js +4 -1
- package/dist/unix/validate/isValidUnixUnit.d.ts +1 -1
- package/dist/utc/calculate/addUtc.js +4 -7
- package/dist/utc/calculate/setUtc.d.ts +16 -3
- package/dist/utc/calculate/setUtc.js +22 -8
- package/dist/utc/calculate/subtractUtc.js +4 -7
- package/dist/utc/convert/convertUtcToPlainDate.d.ts +8 -2
- package/dist/utc/convert/convertUtcToPlainDate.js +10 -7
- package/dist/utc/convert/convertUtcToPlainDateTime.d.ts +9 -2
- package/dist/utc/convert/convertUtcToPlainDateTime.js +12 -13
- package/dist/utc/convert/convertUtcToPlainTime.d.ts +5 -2
- package/dist/utc/convert/convertUtcToPlainTime.js +7 -6
- package/dist/utc/convert/convertUtcToZoned.d.ts +5 -1
- package/dist/utc/convert/convertUtcToZoned.js +5 -1
- package/dist/utc/format/formatCalendarUtc.d.ts +6 -2
- package/dist/utc/format/formatCalendarUtc.js +6 -1
- package/dist/utc/format/{formatHttp.d.ts → formatHttpDate.d.ts} +7 -7
- package/dist/utc/format/{formatHttp.js → formatHttpDate.js} +7 -7
- package/dist/utc/format/formatRelativeUtc.d.ts +11 -3
- package/dist/utc/format/formatRelativeUtc.js +13 -5
- package/dist/utc/format/formatUtc.d.ts +7 -2
- package/dist/utc/format/formatUtc.js +4 -0
- package/dist/utc/format/index.d.ts +1 -1
- package/dist/utc/format/index.js +1 -1
- package/dist/utc/get/getUtcDay.d.ts +1 -3
- package/dist/utc/get/getUtcDay.js +5 -12
- package/dist/utc/get/getUtcHour.d.ts +1 -3
- package/dist/utc/get/getUtcHour.js +5 -12
- package/dist/utc/get/getUtcMicrosecond.d.ts +1 -3
- package/dist/utc/get/getUtcMicrosecond.js +4 -11
- package/dist/utc/get/getUtcMillisecond.d.ts +1 -3
- package/dist/utc/get/getUtcMillisecond.js +5 -12
- package/dist/utc/get/getUtcMinute.d.ts +1 -3
- package/dist/utc/get/getUtcMinute.js +5 -12
- package/dist/utc/get/getUtcMonth.d.ts +1 -3
- package/dist/utc/get/getUtcMonth.js +5 -12
- package/dist/utc/get/getUtcNanosecond.d.ts +1 -3
- package/dist/utc/get/getUtcNanosecond.js +4 -11
- package/dist/utc/get/getUtcNow.d.ts +1 -3
- package/dist/utc/get/getUtcNow.js +2 -9
- package/dist/utc/get/getUtcNowUnit.d.ts +2 -0
- package/dist/utc/get/getUtcNowUnit.js +2 -0
- package/dist/utc/get/getUtcSecond.d.ts +1 -3
- package/dist/utc/get/getUtcSecond.js +5 -12
- package/dist/utc/get/getUtcYear.d.ts +3 -3
- package/dist/utc/get/getUtcYear.js +5 -12
- package/dist/utc/interval/intervalXorAllUtc.js +2 -2
- package/dist/utc/interval/mergeIntervalsUtc.js +2 -2
- package/dist/utc/parse/index.d.ts +1 -1
- package/dist/utc/parse/index.js +1 -1
- package/dist/utc/parse/parseDateFromUtc.d.ts +4 -2
- package/dist/utc/parse/parseDateFromUtc.js +2 -2
- package/dist/utc/parse/parseDayFromUtc.d.ts +4 -2
- package/dist/utc/parse/parseDayFromUtc.js +2 -2
- package/dist/utc/parse/parseDayOfWeekFromUtc.d.ts +4 -2
- package/dist/utc/parse/parseDayOfWeekFromUtc.js +4 -4
- package/dist/utc/parse/parseHourFromUtc.d.ts +4 -2
- package/dist/utc/parse/parseHourFromUtc.js +2 -2
- package/dist/utc/parse/{parseHttp.d.ts → parseHttpDate.d.ts} +12 -12
- package/dist/utc/parse/{parseHttp.js → parseHttpDate.js} +12 -12
- package/dist/utc/parse/parseMicrosecondFromUtc.d.ts +4 -2
- package/dist/utc/parse/parseMicrosecondFromUtc.js +2 -2
- package/dist/utc/parse/parseMillisecondFromUtc.d.ts +4 -2
- package/dist/utc/parse/parseMillisecondFromUtc.js +2 -2
- package/dist/utc/parse/parseMinuteFromUtc.d.ts +4 -2
- package/dist/utc/parse/parseMinuteFromUtc.js +2 -2
- package/dist/utc/parse/parseMonthFromUtc.d.ts +4 -2
- package/dist/utc/parse/parseMonthFromUtc.js +2 -2
- package/dist/utc/parse/parseNanosecondFromUtc.d.ts +4 -2
- package/dist/utc/parse/parseNanosecondFromUtc.js +2 -2
- package/dist/utc/parse/parseSecondFromUtc.d.ts +4 -2
- package/dist/utc/parse/parseSecondFromUtc.js +2 -2
- package/dist/utc/parse/parseTimeFromUtc.d.ts +5 -2
- package/dist/utc/parse/parseTimeFromUtc.js +5 -4
- package/dist/utc/parse/parseUnitFromUtc.d.ts +10 -3
- package/dist/utc/parse/parseUnitFromUtc.js +11 -5
- package/dist/utc/parse/parseWeekFromUtc.d.ts +4 -2
- package/dist/utc/parse/parseWeekFromUtc.js +4 -4
- package/dist/utc/parse/parseYearFromUtc.d.ts +8 -4
- package/dist/utc/parse/parseYearFromUtc.js +8 -5
- package/dist/utc/validate/index.d.ts +2 -0
- package/dist/utc/validate/index.js +2 -0
- package/dist/utc/validate/isValidHttpDate.d.ts +35 -0
- package/dist/utc/validate/isValidHttpDate.js +38 -0
- package/dist/utc/validate/isValidUtc.d.ts +4 -0
- package/dist/utc/validate/isValidUtc.js +4 -0
- package/dist/utc/validate/isValidUtcTimestamp.d.ts +43 -0
- package/dist/utc/validate/isValidUtcTimestamp.js +48 -0
- package/dist/zoned/calculate/addZoned.js +4 -7
- package/dist/zoned/calculate/setZoned.d.ts +19 -5
- package/dist/zoned/calculate/setZoned.js +26 -9
- package/dist/zoned/calculate/subtractZoned.js +4 -7
- package/dist/zoned/convert/convertPlainDateTimeToZoned.d.ts +4 -1
- package/dist/zoned/convert/convertPlainDateTimeToZoned.js +4 -1
- package/dist/zoned/convert/convertZonedToZoned.d.ts +5 -1
- package/dist/zoned/convert/convertZonedToZoned.js +5 -1
- package/dist/zoned/format/formatCalendarZoned.js +2 -1
- package/dist/zoned/format/formatRelativeZoned.js +2 -1
- package/dist/zoned/format/formatTimeZoneName.d.ts +5 -1
- package/dist/zoned/format/formatTimeZoneName.js +5 -1
- package/dist/zoned/get/getDstTransitions.d.ts +5 -3
- package/dist/zoned/get/getDstTransitions.js +12 -7
- package/dist/zoned/get/getSystemTimeZone.d.ts +3 -1
- package/dist/zoned/get/getSystemTimeZone.js +5 -2
- package/dist/zoned/get/getTimeZoneOffset.d.ts +10 -2
- package/dist/zoned/get/getTimeZoneOffset.js +18 -5
- package/dist/zoned/get/getZonedDay.d.ts +2 -1
- package/dist/zoned/get/getZonedDay.js +6 -7
- package/dist/zoned/get/getZonedDayOfWeek.d.ts +2 -1
- package/dist/zoned/get/getZonedDayOfWeek.js +6 -5
- package/dist/zoned/get/getZonedHour.d.ts +2 -1
- package/dist/zoned/get/getZonedHour.js +6 -7
- package/dist/zoned/get/getZonedMicrosecond.d.ts +2 -1
- package/dist/zoned/get/getZonedMicrosecond.js +6 -5
- package/dist/zoned/get/getZonedMillisecond.d.ts +2 -1
- package/dist/zoned/get/getZonedMillisecond.js +6 -7
- package/dist/zoned/get/getZonedMinute.d.ts +2 -1
- package/dist/zoned/get/getZonedMinute.js +6 -7
- package/dist/zoned/get/getZonedMonth.d.ts +2 -1
- package/dist/zoned/get/getZonedMonth.js +6 -7
- package/dist/zoned/get/getZonedNanosecond.d.ts +2 -1
- package/dist/zoned/get/getZonedNanosecond.js +6 -5
- package/dist/zoned/get/getZonedNow.d.ts +5 -1
- package/dist/zoned/get/getZonedNow.js +5 -1
- package/dist/zoned/get/getZonedNowUnit.d.ts +6 -3
- package/dist/zoned/get/getZonedNowUnit.js +10 -7
- package/dist/zoned/get/getZonedSecond.d.ts +2 -1
- package/dist/zoned/get/getZonedSecond.js +6 -7
- package/dist/zoned/get/getZonedToday.d.ts +2 -1
- package/dist/zoned/get/getZonedToday.js +6 -5
- package/dist/zoned/get/getZonedWeekOfYear.d.ts +2 -1
- package/dist/zoned/get/getZonedWeekOfYear.js +6 -5
- package/dist/zoned/get/getZonedYear.d.ts +4 -1
- package/dist/zoned/get/getZonedYear.js +9 -7
- package/dist/zoned/interval/intervalXorAllZoned.js +2 -2
- package/dist/zoned/interval/mergeIntervalsZoned.js +2 -2
- package/dist/zoned/parse/parseUnitFromZoned.d.ts +4 -1
- package/dist/zoned/parse/parseUnitFromZoned.js +5 -1
- package/dist/zoned/parse/parseYearFromZoned.d.ts +4 -2
- package/dist/zoned/parse/parseYearFromZoned.js +6 -3
- package/dist/zoned/validate/hasDaylightSaving.d.ts +4 -2
- package/dist/zoned/validate/hasDaylightSaving.js +13 -7
- package/dist/zoned/validate/index.d.ts +2 -0
- package/dist/zoned/validate/index.js +2 -0
- package/dist/zoned/validate/isValidRfc2822DateTime.d.ts +32 -0
- package/dist/zoned/validate/isValidRfc2822DateTime.js +35 -0
- package/dist/zoned/validate/isValidRfc3339DateTime.d.ts +31 -0
- package/dist/zoned/validate/isValidRfc3339DateTime.js +34 -0
- package/dist/zoned/validate/isValidTimeZone.d.ts +5 -1
- package/dist/zoned/validate/isValidTimeZone.js +6 -2
- package/package.json +50 -1
- package/skills/gmt-arithmetic/SKILL.md +99 -12
- package/skills/gmt-basics/SKILL.md +57 -15
- package/skills/gmt-integration/SKILL.md +24 -9
- package/skills/gmt-timezone/SKILL.md +134 -29
- package/dist/internal/unixZonedDateTime.d.ts +0 -22
- package/dist/internal/unixZonedDateTime.js +0 -32
- package/dist/internal/utcZonedDateTime.d.ts +0 -19
- package/dist/internal/utcZonedDateTime.js +0 -31
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validate whether a value carries the two required time fields of a GS1 EPCIS 2.0 event, each in
|
|
3
|
+
* the grammar GS1 publishes for it.
|
|
4
|
+
*
|
|
5
|
+
* EPCIS (ISO/IEC 19987) is GS1's event standard for supply-chain visibility. True exactly when
|
|
6
|
+
* `isValidEpcisEventTime` is true of `eventTime` and `isValidEpcisTimeZoneOffset` is true of
|
|
7
|
+
* `eventTimeZoneOffset`: this validator calls the two, and no check needs both fields at once.
|
|
8
|
+
* `parseEpcisEvent` returns a result for exactly the same values.
|
|
9
|
+
*
|
|
10
|
+
* - `eventTime` must match `epcisEventTime` (the `DateTimeStamp` pattern of the EPCIS XSD, the
|
|
11
|
+
* XML binding; the JSON schema says only `format: date-time`) and name a real instant: `YYYY-MM-DDTHH:MM:SS`, an optional fraction of up to nine digits, then
|
|
12
|
+
* `Z` or a `±HH:MM` offset. A day the month does not have (`2024-02-30`) is false, although the
|
|
13
|
+
* pattern matches it.
|
|
14
|
+
* - `eventTimeZoneOffset` must match `epcisTimeZoneOffset` (the pattern the EPCIS JSON schema
|
|
15
|
+
* gives; the XSD types the field as a bare `xsd:string`): `±HH:MM` from `-14:00` to `+14:00`,
|
|
16
|
+
* the rule of EPCIS Standard Release 2.0 §7.4.1 (https://ref.gs1.org/standards/epcis/). A
|
|
17
|
+
* missing offset, `Z`, `+0200` and `+02` are false.
|
|
18
|
+
* - The two fields are independent: an `eventTime` written with one offset and an
|
|
19
|
+
* `eventTimeZoneOffset` that is another is valid. EPCIS 2.0 §7.4.1.1 (non-normative): "there
|
|
20
|
+
* is no requirement that the time zone specifier in the XML representation of eventTime be the
|
|
21
|
+
* local time zone offset where the event was captured".
|
|
22
|
+
* - **GMT rule:** a fraction longer than nine digits is false. The XSD allows any length; an
|
|
23
|
+
* instant holds nanoseconds, and `parseEpcisEvent` does not drop digits.
|
|
24
|
+
* - Only the two fields are checked. `recordTime` and every other member are ignored, so this
|
|
25
|
+
* does not validate a whole event against the EPCIS schema.
|
|
26
|
+
* - Returns false for a value that is not an object.
|
|
27
|
+
*
|
|
28
|
+
* @param event candidate EPCIS event, or any object with `eventTime` and `eventTimeZoneOffset`
|
|
29
|
+
* @returns boolean indicating whether `parseEpcisEvent` reads the event, or false on invalid input
|
|
30
|
+
*
|
|
31
|
+
* @example isValidEpcisEvent({ eventTime: "2024-06-15T14:30:00Z", eventTimeZoneOffset: "-05:00" }) // true
|
|
32
|
+
* @example isValidEpcisEvent({ eventTime: "2024-06-15T10:00:00+02:00", eventTimeZoneOffset: "-05:00" }) // true (the two offsets need not agree)
|
|
33
|
+
* @example isValidEpcisEvent({ eventTime: "2024-06-15T14:30:00.123456789Z", eventTimeZoneOffset: "+14:00" }) // true
|
|
34
|
+
* @example isValidEpcisEvent({ eventTime: "2024-06-15T14:30:00Z" }) // false (eventTimeZoneOffset is required)
|
|
35
|
+
* @example isValidEpcisEvent({ eventTime: "2024-06-15T14:30:00Z", eventTimeZoneOffset: "Z" }) // false (a designator, not an offset)
|
|
36
|
+
* @example isValidEpcisEvent({ eventTime: "2024-06-15T14:30:00Z", eventTimeZoneOffset: "+0200" }) // false (no colon)
|
|
37
|
+
* @example isValidEpcisEvent({ eventTime: "2024-06-15T14:30Z", eventTimeZoneOffset: "-05:00" }) // false (seconds are required)
|
|
38
|
+
* @example isValidEpcisEvent({ eventTime: "2024-02-30T14:30:00Z", eventTimeZoneOffset: "-05:00" }) // false (30 February)
|
|
39
|
+
* @example isValidEpcisEvent("2024-06-15T14:30:00Z") // false (not an event)
|
|
40
|
+
*/
|
|
41
|
+
export declare function isValidEpcisEvent(event: unknown): boolean;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { isObject } from "../../internal/index.js";
|
|
2
|
+
import { isValidEpcisEventTime } from "./isValidEpcisEventTime.js";
|
|
3
|
+
import { isValidEpcisTimeZoneOffset } from "./isValidEpcisTimeZoneOffset.js";
|
|
4
|
+
/**
|
|
5
|
+
* Validate whether a value carries the two required time fields of a GS1 EPCIS 2.0 event, each in
|
|
6
|
+
* the grammar GS1 publishes for it.
|
|
7
|
+
*
|
|
8
|
+
* EPCIS (ISO/IEC 19987) is GS1's event standard for supply-chain visibility. True exactly when
|
|
9
|
+
* `isValidEpcisEventTime` is true of `eventTime` and `isValidEpcisTimeZoneOffset` is true of
|
|
10
|
+
* `eventTimeZoneOffset`: this validator calls the two, and no check needs both fields at once.
|
|
11
|
+
* `parseEpcisEvent` returns a result for exactly the same values.
|
|
12
|
+
*
|
|
13
|
+
* - `eventTime` must match `epcisEventTime` (the `DateTimeStamp` pattern of the EPCIS XSD, the
|
|
14
|
+
* XML binding; the JSON schema says only `format: date-time`) and name a real instant: `YYYY-MM-DDTHH:MM:SS`, an optional fraction of up to nine digits, then
|
|
15
|
+
* `Z` or a `±HH:MM` offset. A day the month does not have (`2024-02-30`) is false, although the
|
|
16
|
+
* pattern matches it.
|
|
17
|
+
* - `eventTimeZoneOffset` must match `epcisTimeZoneOffset` (the pattern the EPCIS JSON schema
|
|
18
|
+
* gives; the XSD types the field as a bare `xsd:string`): `±HH:MM` from `-14:00` to `+14:00`,
|
|
19
|
+
* the rule of EPCIS Standard Release 2.0 §7.4.1 (https://ref.gs1.org/standards/epcis/). A
|
|
20
|
+
* missing offset, `Z`, `+0200` and `+02` are false.
|
|
21
|
+
* - The two fields are independent: an `eventTime` written with one offset and an
|
|
22
|
+
* `eventTimeZoneOffset` that is another is valid. EPCIS 2.0 §7.4.1.1 (non-normative): "there
|
|
23
|
+
* is no requirement that the time zone specifier in the XML representation of eventTime be the
|
|
24
|
+
* local time zone offset where the event was captured".
|
|
25
|
+
* - **GMT rule:** a fraction longer than nine digits is false. The XSD allows any length; an
|
|
26
|
+
* instant holds nanoseconds, and `parseEpcisEvent` does not drop digits.
|
|
27
|
+
* - Only the two fields are checked. `recordTime` and every other member are ignored, so this
|
|
28
|
+
* does not validate a whole event against the EPCIS schema.
|
|
29
|
+
* - Returns false for a value that is not an object.
|
|
30
|
+
*
|
|
31
|
+
* @param event candidate EPCIS event, or any object with `eventTime` and `eventTimeZoneOffset`
|
|
32
|
+
* @returns boolean indicating whether `parseEpcisEvent` reads the event, or false on invalid input
|
|
33
|
+
*
|
|
34
|
+
* @example isValidEpcisEvent({ eventTime: "2024-06-15T14:30:00Z", eventTimeZoneOffset: "-05:00" }) // true
|
|
35
|
+
* @example isValidEpcisEvent({ eventTime: "2024-06-15T10:00:00+02:00", eventTimeZoneOffset: "-05:00" }) // true (the two offsets need not agree)
|
|
36
|
+
* @example isValidEpcisEvent({ eventTime: "2024-06-15T14:30:00.123456789Z", eventTimeZoneOffset: "+14:00" }) // true
|
|
37
|
+
* @example isValidEpcisEvent({ eventTime: "2024-06-15T14:30:00Z" }) // false (eventTimeZoneOffset is required)
|
|
38
|
+
* @example isValidEpcisEvent({ eventTime: "2024-06-15T14:30:00Z", eventTimeZoneOffset: "Z" }) // false (a designator, not an offset)
|
|
39
|
+
* @example isValidEpcisEvent({ eventTime: "2024-06-15T14:30:00Z", eventTimeZoneOffset: "+0200" }) // false (no colon)
|
|
40
|
+
* @example isValidEpcisEvent({ eventTime: "2024-06-15T14:30Z", eventTimeZoneOffset: "-05:00" }) // false (seconds are required)
|
|
41
|
+
* @example isValidEpcisEvent({ eventTime: "2024-02-30T14:30:00Z", eventTimeZoneOffset: "-05:00" }) // false (30 February)
|
|
42
|
+
* @example isValidEpcisEvent("2024-06-15T14:30:00Z") // false (not an event)
|
|
43
|
+
*/
|
|
44
|
+
export function isValidEpcisEvent(event) {
|
|
45
|
+
try {
|
|
46
|
+
if (!isObject(event)) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
// Each field is read once, in the order `parseEpcisEvent` reads them.
|
|
50
|
+
const { eventTime, eventTimeZoneOffset } = event;
|
|
51
|
+
return (isValidEpcisEventTime(eventTime) &&
|
|
52
|
+
isValidEpcisTimeZoneOffset(eventTimeZoneOffset));
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
// Never throws (Core Rule 3): a hostile argument is invalid input, not an exception.
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return true when `value` is a real GS1 EPCIS 2.0 `eventTime`: the moment a supply-chain event
|
|
3
|
+
* happened, written as a date and time with `Z` or a UTC offset.
|
|
4
|
+
*
|
|
5
|
+
* EPCIS (ISO/IEC 19987) is GS1's event standard for supply-chain visibility. This is the check
|
|
6
|
+
* `isValidEpcisEvent` applies to the event's `eventTime` field: that validator calls this one.
|
|
7
|
+
*
|
|
8
|
+
* - The value must match `epcisEventTime`, the `DateTimeStamp` pattern of the EPCIS XSD:
|
|
9
|
+
* `YYYY-MM-DDTHH:MM:SS`, an optional fraction, then `Z` or a `±HH:MM` offset up to `14:00`.
|
|
10
|
+
* Seconds are required, `T` and `Z` are upper-case, and nothing may follow.
|
|
11
|
+
* - Checks the calendar as well as the shape. The pattern proves the shape alone, so it matches
|
|
12
|
+
* a day the month does not have: `2024-02-30` and `2023-02-29` are false here.
|
|
13
|
+
* - **GMT rule:** a fraction longer than nine digits is false, although the pattern matches a
|
|
14
|
+
* fraction of any length. An instant holds nanoseconds, and `parseEpcisEvent` does not drop
|
|
15
|
+
* digits.
|
|
16
|
+
* - False for a leap second (`:60`), a space separator, an expanded year and a bracketed zone,
|
|
17
|
+
* none of which the pattern matches.
|
|
18
|
+
* - An event also needs an `eventTimeZoneOffset`: check it with `isValidEpcisTimeZoneOffset`, or
|
|
19
|
+
* both fields with `isValidEpcisEvent`. Read an event with `parseEpcisEvent`.
|
|
20
|
+
* - False for a non-string.
|
|
21
|
+
*
|
|
22
|
+
* @param value candidate EPCIS `eventTime` string
|
|
23
|
+
* @returns boolean indicating validity
|
|
24
|
+
*
|
|
25
|
+
* @example isValidEpcisEventTime("2024-06-15T14:30:00Z") // true
|
|
26
|
+
* @example isValidEpcisEventTime("2024-06-15T10:00:00.123+02:00") // true
|
|
27
|
+
* @example isValidEpcisEventTime("2024-02-30T14:30:00Z") // false (30 February; the epcisEventTime pattern matches it)
|
|
28
|
+
* @example isValidEpcisEventTime("2023-02-29T00:00:00Z") // false (2023 has no 29 February; the epcisEventTime pattern matches it)
|
|
29
|
+
* @example isValidEpcisEventTime("2024-06-15T14:30:00.1234567891Z") // false (finer than a nanosecond; the epcisEventTime pattern matches it)
|
|
30
|
+
* @example isValidEpcisEventTime("2024-06-15T14:30Z") // false (seconds are required)
|
|
31
|
+
* @example isValidEpcisEventTime("2024-06-15T14:30:00") // false (Z or an offset is required)
|
|
32
|
+
*/
|
|
33
|
+
export declare function isValidEpcisEventTime(value: string): boolean;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
+
import { epcisEventTime } from "../../regex/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Return true when `value` is a real GS1 EPCIS 2.0 `eventTime`: the moment a supply-chain event
|
|
5
|
+
* happened, written as a date and time with `Z` or a UTC offset.
|
|
6
|
+
*
|
|
7
|
+
* EPCIS (ISO/IEC 19987) is GS1's event standard for supply-chain visibility. This is the check
|
|
8
|
+
* `isValidEpcisEvent` applies to the event's `eventTime` field: that validator calls this one.
|
|
9
|
+
*
|
|
10
|
+
* - The value must match `epcisEventTime`, the `DateTimeStamp` pattern of the EPCIS XSD:
|
|
11
|
+
* `YYYY-MM-DDTHH:MM:SS`, an optional fraction, then `Z` or a `±HH:MM` offset up to `14:00`.
|
|
12
|
+
* Seconds are required, `T` and `Z` are upper-case, and nothing may follow.
|
|
13
|
+
* - Checks the calendar as well as the shape. The pattern proves the shape alone, so it matches
|
|
14
|
+
* a day the month does not have: `2024-02-30` and `2023-02-29` are false here.
|
|
15
|
+
* - **GMT rule:** a fraction longer than nine digits is false, although the pattern matches a
|
|
16
|
+
* fraction of any length. An instant holds nanoseconds, and `parseEpcisEvent` does not drop
|
|
17
|
+
* digits.
|
|
18
|
+
* - False for a leap second (`:60`), a space separator, an expanded year and a bracketed zone,
|
|
19
|
+
* none of which the pattern matches.
|
|
20
|
+
* - An event also needs an `eventTimeZoneOffset`: check it with `isValidEpcisTimeZoneOffset`, or
|
|
21
|
+
* both fields with `isValidEpcisEvent`. Read an event with `parseEpcisEvent`.
|
|
22
|
+
* - False for a non-string.
|
|
23
|
+
*
|
|
24
|
+
* @param value candidate EPCIS `eventTime` string
|
|
25
|
+
* @returns boolean indicating validity
|
|
26
|
+
*
|
|
27
|
+
* @example isValidEpcisEventTime("2024-06-15T14:30:00Z") // true
|
|
28
|
+
* @example isValidEpcisEventTime("2024-06-15T10:00:00.123+02:00") // true
|
|
29
|
+
* @example isValidEpcisEventTime("2024-02-30T14:30:00Z") // false (30 February; the epcisEventTime pattern matches it)
|
|
30
|
+
* @example isValidEpcisEventTime("2023-02-29T00:00:00Z") // false (2023 has no 29 February; the epcisEventTime pattern matches it)
|
|
31
|
+
* @example isValidEpcisEventTime("2024-06-15T14:30:00.1234567891Z") // false (finer than a nanosecond; the epcisEventTime pattern matches it)
|
|
32
|
+
* @example isValidEpcisEventTime("2024-06-15T14:30Z") // false (seconds are required)
|
|
33
|
+
* @example isValidEpcisEventTime("2024-06-15T14:30:00") // false (Z or an offset is required)
|
|
34
|
+
*/
|
|
35
|
+
export function isValidEpcisEventTime(value) {
|
|
36
|
+
if (typeof value !== "string" || !epcisEventTime.test(value)) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
// The two checks the pattern cannot make: a day the month does not have, and a fraction past
|
|
41
|
+
// nine digits (Temporal's grammar stops at nanoseconds). Both are a RangeError.
|
|
42
|
+
Temporal.Instant.from(value);
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return true when `value` is a GS1 EPCIS 2.0 `eventTimeZoneOffset`: the UTC offset the local
|
|
3
|
+
* clock ran at where a supply-chain event happened, written `±HH:MM`.
|
|
4
|
+
*
|
|
5
|
+
* EPCIS (ISO/IEC 19987) is GS1's event standard for supply-chain visibility. This is the check
|
|
6
|
+
* `isValidEpcisEvent` applies to the event's `eventTimeZoneOffset` field: that validator calls
|
|
7
|
+
* this one.
|
|
8
|
+
*
|
|
9
|
+
* - The value must match `epcisTimeZoneOffset`, the pattern the EPCIS JSON schema gives: `±HH:MM`
|
|
10
|
+
* from `-14:00` to `+14:00`, the rule of EPCIS Standard Release 2.0 §7.4.1
|
|
11
|
+
* (https://ref.gs1.org/standards/epcis/).
|
|
12
|
+
* - **The pattern is the whole rule for a string.** Every value it matches is an offset Temporal
|
|
13
|
+
* reads, so this validator and `epcisTimeZoneOffset.test` agree on every string; the validator
|
|
14
|
+
* adds only the answer false for a non-string.
|
|
15
|
+
* - `Z`, `+0200`, `+02`, an offset with seconds and an offset past `14:00` are false.
|
|
16
|
+
* - `-00:00` is true: the GS1 pattern matches it. `parseEpcisEvent` returns it as `+00:00`.
|
|
17
|
+
* - It need not agree with an offset written in the event's `eventTime`. Check that field with
|
|
18
|
+
* `isValidEpcisEventTime`, or both with `isValidEpcisEvent`.
|
|
19
|
+
*
|
|
20
|
+
* @param value candidate EPCIS `eventTimeZoneOffset` string
|
|
21
|
+
* @returns boolean indicating validity
|
|
22
|
+
*
|
|
23
|
+
* @example isValidEpcisTimeZoneOffset("-05:00") // true
|
|
24
|
+
* @example isValidEpcisTimeZoneOffset("+14:00") // true
|
|
25
|
+
* @example isValidEpcisTimeZoneOffset("+14:01") // false (past the range GS1 allows)
|
|
26
|
+
* @example isValidEpcisTimeZoneOffset("Z") // false (a designator, not an offset)
|
|
27
|
+
* @example isValidEpcisTimeZoneOffset("+0200") // false (no colon)
|
|
28
|
+
* @example isValidEpcisTimeZoneOffset("+05:30:00") // false (seconds)
|
|
29
|
+
*/
|
|
30
|
+
export declare function isValidEpcisTimeZoneOffset(value: string): boolean;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { parseUtcOffsetNanoseconds } from "../../internal/index.js";
|
|
2
|
+
import { epcisTimeZoneOffset } from "../../regex/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Return true when `value` is a GS1 EPCIS 2.0 `eventTimeZoneOffset`: the UTC offset the local
|
|
5
|
+
* clock ran at where a supply-chain event happened, written `±HH:MM`.
|
|
6
|
+
*
|
|
7
|
+
* EPCIS (ISO/IEC 19987) is GS1's event standard for supply-chain visibility. This is the check
|
|
8
|
+
* `isValidEpcisEvent` applies to the event's `eventTimeZoneOffset` field: that validator calls
|
|
9
|
+
* this one.
|
|
10
|
+
*
|
|
11
|
+
* - The value must match `epcisTimeZoneOffset`, the pattern the EPCIS JSON schema gives: `±HH:MM`
|
|
12
|
+
* from `-14:00` to `+14:00`, the rule of EPCIS Standard Release 2.0 §7.4.1
|
|
13
|
+
* (https://ref.gs1.org/standards/epcis/).
|
|
14
|
+
* - **The pattern is the whole rule for a string.** Every value it matches is an offset Temporal
|
|
15
|
+
* reads, so this validator and `epcisTimeZoneOffset.test` agree on every string; the validator
|
|
16
|
+
* adds only the answer false for a non-string.
|
|
17
|
+
* - `Z`, `+0200`, `+02`, an offset with seconds and an offset past `14:00` are false.
|
|
18
|
+
* - `-00:00` is true: the GS1 pattern matches it. `parseEpcisEvent` returns it as `+00:00`.
|
|
19
|
+
* - It need not agree with an offset written in the event's `eventTime`. Check that field with
|
|
20
|
+
* `isValidEpcisEventTime`, or both with `isValidEpcisEvent`.
|
|
21
|
+
*
|
|
22
|
+
* @param value candidate EPCIS `eventTimeZoneOffset` string
|
|
23
|
+
* @returns boolean indicating validity
|
|
24
|
+
*
|
|
25
|
+
* @example isValidEpcisTimeZoneOffset("-05:00") // true
|
|
26
|
+
* @example isValidEpcisTimeZoneOffset("+14:00") // true
|
|
27
|
+
* @example isValidEpcisTimeZoneOffset("+14:01") // false (past the range GS1 allows)
|
|
28
|
+
* @example isValidEpcisTimeZoneOffset("Z") // false (a designator, not an offset)
|
|
29
|
+
* @example isValidEpcisTimeZoneOffset("+0200") // false (no colon)
|
|
30
|
+
* @example isValidEpcisTimeZoneOffset("+05:30:00") // false (seconds)
|
|
31
|
+
*/
|
|
32
|
+
export function isValidEpcisTimeZoneOffset(value) {
|
|
33
|
+
// `parseEpcisEvent` reads the offset through Temporal after the pattern, so this does too. No
|
|
34
|
+
// string the pattern matches fails that read: it is here so the two cannot drift.
|
|
35
|
+
return (typeof value === "string" &&
|
|
36
|
+
epcisTimeZoneOffset.test(value) &&
|
|
37
|
+
parseUtcOffsetNanoseconds(value) !== null);
|
|
38
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { X12DateFormat } from "../../types/edi.js";
|
|
2
|
+
/**
|
|
3
|
+
* Return true when `value` is an X12 Date Time Period value (data element 1251) that states a
|
|
4
|
+
* real calendar date in a date format qualifier (data element 1250).
|
|
5
|
+
*
|
|
6
|
+
* ### Format codes
|
|
7
|
+
* | Code | Mask | The dictionary's definition |
|
|
8
|
+
* |---|---|---|
|
|
9
|
+
* | `D8` | `CCYYMMDD` | "Date Expressed in Format CCYYMMDD" |
|
|
10
|
+
* | `DB` | `MMDDCCYY` | "Date Expressed in Format MMDDCCYY" |
|
|
11
|
+
*
|
|
12
|
+
* - True exactly when `parseX12Date` returns a date for the same arguments: the validator calls
|
|
13
|
+
* the parser, so the two cannot disagree.
|
|
14
|
+
* - A value is valid only against its code: `"06152024"` is a `DB` value and not a `D8` one.
|
|
15
|
+
* - Checks the calendar as well as the shape: 31 June and 29 February 2023 are false.
|
|
16
|
+
* - False for any other code, a code of another kind included; check a code alone with
|
|
17
|
+
* `isValidX12DateTimePeriodFormat`. False for a non-string argument.
|
|
18
|
+
*
|
|
19
|
+
* @param value The data element 1251 value (e.g. "20240615")
|
|
20
|
+
* @param format X12 data element 1250 format qualifier
|
|
21
|
+
* @returns boolean indicating validity
|
|
22
|
+
*
|
|
23
|
+
* @example isValidX12Date("20240615", "D8") // true
|
|
24
|
+
* @example isValidX12Date("06152024", "DB") // true
|
|
25
|
+
* @example isValidX12Date("06152024", "D8") // false (20 is not a month)
|
|
26
|
+
* @example isValidX12Date("20230229", "D8") // false (2023 has no 29 February)
|
|
27
|
+
*/
|
|
28
|
+
export declare function isValidX12Date(value: string, format: X12DateFormat): boolean;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { parseX12Date } from "../parse/parseX12Date.js";
|
|
2
|
+
/**
|
|
3
|
+
* Return true when `value` is an X12 Date Time Period value (data element 1251) that states a
|
|
4
|
+
* real calendar date in a date format qualifier (data element 1250).
|
|
5
|
+
*
|
|
6
|
+
* ### Format codes
|
|
7
|
+
* | Code | Mask | The dictionary's definition |
|
|
8
|
+
* |---|---|---|
|
|
9
|
+
* | `D8` | `CCYYMMDD` | "Date Expressed in Format CCYYMMDD" |
|
|
10
|
+
* | `DB` | `MMDDCCYY` | "Date Expressed in Format MMDDCCYY" |
|
|
11
|
+
*
|
|
12
|
+
* - True exactly when `parseX12Date` returns a date for the same arguments: the validator calls
|
|
13
|
+
* the parser, so the two cannot disagree.
|
|
14
|
+
* - A value is valid only against its code: `"06152024"` is a `DB` value and not a `D8` one.
|
|
15
|
+
* - Checks the calendar as well as the shape: 31 June and 29 February 2023 are false.
|
|
16
|
+
* - False for any other code, a code of another kind included; check a code alone with
|
|
17
|
+
* `isValidX12DateTimePeriodFormat`. False for a non-string argument.
|
|
18
|
+
*
|
|
19
|
+
* @param value The data element 1251 value (e.g. "20240615")
|
|
20
|
+
* @param format X12 data element 1250 format qualifier
|
|
21
|
+
* @returns boolean indicating validity
|
|
22
|
+
*
|
|
23
|
+
* @example isValidX12Date("20240615", "D8") // true
|
|
24
|
+
* @example isValidX12Date("06152024", "DB") // true
|
|
25
|
+
* @example isValidX12Date("06152024", "D8") // false (20 is not a month)
|
|
26
|
+
* @example isValidX12Date("20230229", "D8") // false (2023 has no 29 February)
|
|
27
|
+
*/
|
|
28
|
+
export function isValidX12Date(value, format) {
|
|
29
|
+
return parseX12Date(value, format) !== "";
|
|
30
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return true when the date and the time of an X12 segment, sent as two elements, together
|
|
3
|
+
* state a real local date and time.
|
|
4
|
+
*
|
|
5
|
+
* ### The two elements
|
|
6
|
+
* | Element | Name | The dictionary's definition |
|
|
7
|
+
* |---|---|---|
|
|
8
|
+
* | [373](https://www.stedi.com/edi/x12-005010/element/373) | Date | "Date expressed as CCYYMMDD where CC represents the first two digits of the calendar year" |
|
|
9
|
+
* | [337](https://www.stedi.com/edi/x12-005010/element/337) | Time | "Time expressed in 24-hour clock time as follows: HHMM, or HHMMSS, or HHMMSSD, or HHMMSSDD" |
|
|
10
|
+
*
|
|
11
|
+
* - True exactly when `parseX12DateAndTime` returns a date-time for the same arguments: the
|
|
12
|
+
* validator calls the parser, so the two cannot disagree.
|
|
13
|
+
* - **Both elements are required.** A missing or empty date or time is false: check a date alone
|
|
14
|
+
* with `isValidX12Date(value, "D8")` and a time alone with `isValidX12Time`.
|
|
15
|
+
* - Checks the calendar as well as the shape: 29 February 2023, 31 June, hour 24 and minute or
|
|
16
|
+
* second 60 are false.
|
|
17
|
+
* - The date has a four-digit year and the time is 4, 6, 7 or 8 digits: a date of six digits and
|
|
18
|
+
* a time of 5 or 9 digits are false.
|
|
19
|
+
* - False for a non-string argument.
|
|
20
|
+
*
|
|
21
|
+
* @param date The data element 373 date as transmitted, `CCYYMMDD` (e.g. "20240615")
|
|
22
|
+
* @param time The data element 337 time as transmitted (e.g. "1430")
|
|
23
|
+
* @returns boolean indicating validity
|
|
24
|
+
*
|
|
25
|
+
* @example isValidX12DateAndTime("20240615", "1430") // true
|
|
26
|
+
* @example isValidX12DateAndTime("20240615", "14300012") // true (hundredths of a second)
|
|
27
|
+
* @example isValidX12DateAndTime("20240615", "") // false (both elements are required)
|
|
28
|
+
* @example isValidX12DateAndTime("20230229", "1430") // false (2023 has no 29 February)
|
|
29
|
+
* @example isValidX12DateAndTime("20240615", "2430") // false (hour 24)
|
|
30
|
+
* @example isValidX12DateAndTime("240615", "1430") // false (the date element has a four-digit year)
|
|
31
|
+
*/
|
|
32
|
+
export declare function isValidX12DateAndTime(date: string, time: string): boolean;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { parseX12DateAndTime } from "../parse/parseX12DateAndTime.js";
|
|
2
|
+
/**
|
|
3
|
+
* Return true when the date and the time of an X12 segment, sent as two elements, together
|
|
4
|
+
* state a real local date and time.
|
|
5
|
+
*
|
|
6
|
+
* ### The two elements
|
|
7
|
+
* | Element | Name | The dictionary's definition |
|
|
8
|
+
* |---|---|---|
|
|
9
|
+
* | [373](https://www.stedi.com/edi/x12-005010/element/373) | Date | "Date expressed as CCYYMMDD where CC represents the first two digits of the calendar year" |
|
|
10
|
+
* | [337](https://www.stedi.com/edi/x12-005010/element/337) | Time | "Time expressed in 24-hour clock time as follows: HHMM, or HHMMSS, or HHMMSSD, or HHMMSSDD" |
|
|
11
|
+
*
|
|
12
|
+
* - True exactly when `parseX12DateAndTime` returns a date-time for the same arguments: the
|
|
13
|
+
* validator calls the parser, so the two cannot disagree.
|
|
14
|
+
* - **Both elements are required.** A missing or empty date or time is false: check a date alone
|
|
15
|
+
* with `isValidX12Date(value, "D8")` and a time alone with `isValidX12Time`.
|
|
16
|
+
* - Checks the calendar as well as the shape: 29 February 2023, 31 June, hour 24 and minute or
|
|
17
|
+
* second 60 are false.
|
|
18
|
+
* - The date has a four-digit year and the time is 4, 6, 7 or 8 digits: a date of six digits and
|
|
19
|
+
* a time of 5 or 9 digits are false.
|
|
20
|
+
* - False for a non-string argument.
|
|
21
|
+
*
|
|
22
|
+
* @param date The data element 373 date as transmitted, `CCYYMMDD` (e.g. "20240615")
|
|
23
|
+
* @param time The data element 337 time as transmitted (e.g. "1430")
|
|
24
|
+
* @returns boolean indicating validity
|
|
25
|
+
*
|
|
26
|
+
* @example isValidX12DateAndTime("20240615", "1430") // true
|
|
27
|
+
* @example isValidX12DateAndTime("20240615", "14300012") // true (hundredths of a second)
|
|
28
|
+
* @example isValidX12DateAndTime("20240615", "") // false (both elements are required)
|
|
29
|
+
* @example isValidX12DateAndTime("20230229", "1430") // false (2023 has no 29 February)
|
|
30
|
+
* @example isValidX12DateAndTime("20240615", "2430") // false (hour 24)
|
|
31
|
+
* @example isValidX12DateAndTime("240615", "1430") // false (the date element has a four-digit year)
|
|
32
|
+
*/
|
|
33
|
+
export function isValidX12DateAndTime(date, time) {
|
|
34
|
+
return parseX12DateAndTime(date, time) !== "";
|
|
35
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { X12DateRangeFormat } from "../../types/edi.js";
|
|
2
|
+
/**
|
|
3
|
+
* Return true when `value` is an X12 Date Time Period value (data element 1251) that states a
|
|
4
|
+
* range between two real calendar dates, in a date range format qualifier (data element 1250).
|
|
5
|
+
*
|
|
6
|
+
* ### Format codes
|
|
7
|
+
* | Code | Mask | The dictionary's definition |
|
|
8
|
+
* |---|---|---|
|
|
9
|
+
* | `RD8` | `CCYYMMDD-CCYYMMDD` | "Range of Dates Expressed in Format CCYYMMDD-CCYYMMDD" |
|
|
10
|
+
* | `RD` | `MMDDCCYY-MMDDCCYY` | "Range of Dates Expressed in Format MMDDCCYY-MMDDCCYY" |
|
|
11
|
+
*
|
|
12
|
+
* - True exactly when `parseX12DateRange` returns a range for the same arguments: the validator
|
|
13
|
+
* calls the parser, so the two cannot disagree.
|
|
14
|
+
* - A range is valid with exactly one hyphen: `"2024061520240620"` is false.
|
|
15
|
+
* - A range whose end precedes its start is false; an end equal to its start is true.
|
|
16
|
+
* - Checks the calendar as well as the shape: 29 February 2023 in either date is false.
|
|
17
|
+
* - False for any other code, a code of another kind included; check a code alone with
|
|
18
|
+
* `isValidX12DateTimePeriodFormat`. False for a non-string argument.
|
|
19
|
+
*
|
|
20
|
+
* @param value The data element 1251 value (e.g. "20240615-20240620")
|
|
21
|
+
* @param format X12 data element 1250 format qualifier
|
|
22
|
+
* @returns boolean indicating validity
|
|
23
|
+
*
|
|
24
|
+
* @example isValidX12DateRange("20240615-20240620", "RD8") // true
|
|
25
|
+
* @example isValidX12DateRange("06152024-06202024", "RD") // true
|
|
26
|
+
* @example isValidX12DateRange("2024061520240620", "RD8") // false (a range is transmitted with its hyphen)
|
|
27
|
+
* @example isValidX12DateRange("20240620-20240615", "RD8") // false (the end precedes the start)
|
|
28
|
+
*/
|
|
29
|
+
export declare function isValidX12DateRange(value: string, format: X12DateRangeFormat): boolean;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { parseX12DateRange } from "../parse/parseX12DateRange.js";
|
|
2
|
+
/**
|
|
3
|
+
* Return true when `value` is an X12 Date Time Period value (data element 1251) that states a
|
|
4
|
+
* range between two real calendar dates, in a date range format qualifier (data element 1250).
|
|
5
|
+
*
|
|
6
|
+
* ### Format codes
|
|
7
|
+
* | Code | Mask | The dictionary's definition |
|
|
8
|
+
* |---|---|---|
|
|
9
|
+
* | `RD8` | `CCYYMMDD-CCYYMMDD` | "Range of Dates Expressed in Format CCYYMMDD-CCYYMMDD" |
|
|
10
|
+
* | `RD` | `MMDDCCYY-MMDDCCYY` | "Range of Dates Expressed in Format MMDDCCYY-MMDDCCYY" |
|
|
11
|
+
*
|
|
12
|
+
* - True exactly when `parseX12DateRange` returns a range for the same arguments: the validator
|
|
13
|
+
* calls the parser, so the two cannot disagree.
|
|
14
|
+
* - A range is valid with exactly one hyphen: `"2024061520240620"` is false.
|
|
15
|
+
* - A range whose end precedes its start is false; an end equal to its start is true.
|
|
16
|
+
* - Checks the calendar as well as the shape: 29 February 2023 in either date is false.
|
|
17
|
+
* - False for any other code, a code of another kind included; check a code alone with
|
|
18
|
+
* `isValidX12DateTimePeriodFormat`. False for a non-string argument.
|
|
19
|
+
*
|
|
20
|
+
* @param value The data element 1251 value (e.g. "20240615-20240620")
|
|
21
|
+
* @param format X12 data element 1250 format qualifier
|
|
22
|
+
* @returns boolean indicating validity
|
|
23
|
+
*
|
|
24
|
+
* @example isValidX12DateRange("20240615-20240620", "RD8") // true
|
|
25
|
+
* @example isValidX12DateRange("06152024-06202024", "RD") // true
|
|
26
|
+
* @example isValidX12DateRange("2024061520240620", "RD8") // false (a range is transmitted with its hyphen)
|
|
27
|
+
* @example isValidX12DateRange("20240620-20240615", "RD8") // false (the end precedes the start)
|
|
28
|
+
*/
|
|
29
|
+
export function isValidX12DateRange(value, format) {
|
|
30
|
+
return parseX12DateRange(value, format) !== null;
|
|
31
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { X12DateTimeFormat } from "../../types/edi.js";
|
|
2
|
+
/**
|
|
3
|
+
* Return true when `value` is an X12 Date Time Period value (data element 1251) that states a
|
|
4
|
+
* real date and time in a date-time format qualifier (data element 1250).
|
|
5
|
+
*
|
|
6
|
+
* ### Format codes
|
|
7
|
+
* | Code | Mask | The dictionary's definition |
|
|
8
|
+
* |---|---|---|
|
|
9
|
+
* | `DT` | `CCYYMMDDHHMM` | "Date and Time Expressed in Format CCYYMMDDHHMM" |
|
|
10
|
+
* | `RTS` | `CCYYMMDDHHMMSS` | "Date and Time Expressed in Format CCYYMMDDHHMMSS" |
|
|
11
|
+
*
|
|
12
|
+
* - True exactly when `parseX12DateTime` returns a date-time for the same arguments: the
|
|
13
|
+
* validator calls the parser, so the two cannot disagree.
|
|
14
|
+
* - A value is valid only against its code: `"202406151430"` is a `DT` value and not an `RTS`
|
|
15
|
+
* one.
|
|
16
|
+
* - Checks the calendar as well as the shape: 31 June, 29 February 2023, hour 24 and second 60
|
|
17
|
+
* are false.
|
|
18
|
+
* - False for any other code, a code of another kind included; check a code alone with
|
|
19
|
+
* `isValidX12DateTimePeriodFormat`. False for a non-string argument.
|
|
20
|
+
*
|
|
21
|
+
* @param value The data element 1251 value (e.g. "202406151430")
|
|
22
|
+
* @param format X12 data element 1250 format qualifier
|
|
23
|
+
* @returns boolean indicating validity
|
|
24
|
+
*
|
|
25
|
+
* @example isValidX12DateTime("202406151430", "DT") // true
|
|
26
|
+
* @example isValidX12DateTime("20240615143045", "RTS") // true
|
|
27
|
+
* @example isValidX12DateTime("202406151430", "RTS") // false (twelve digits is a DT value)
|
|
28
|
+
* @example isValidX12DateTime("202406152430", "DT") // false (hour 24)
|
|
29
|
+
*/
|
|
30
|
+
export declare function isValidX12DateTime(value: string, format: X12DateTimeFormat): boolean;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { parseX12DateTime } from "../parse/parseX12DateTime.js";
|
|
2
|
+
/**
|
|
3
|
+
* Return true when `value` is an X12 Date Time Period value (data element 1251) that states a
|
|
4
|
+
* real date and time in a date-time format qualifier (data element 1250).
|
|
5
|
+
*
|
|
6
|
+
* ### Format codes
|
|
7
|
+
* | Code | Mask | The dictionary's definition |
|
|
8
|
+
* |---|---|---|
|
|
9
|
+
* | `DT` | `CCYYMMDDHHMM` | "Date and Time Expressed in Format CCYYMMDDHHMM" |
|
|
10
|
+
* | `RTS` | `CCYYMMDDHHMMSS` | "Date and Time Expressed in Format CCYYMMDDHHMMSS" |
|
|
11
|
+
*
|
|
12
|
+
* - True exactly when `parseX12DateTime` returns a date-time for the same arguments: the
|
|
13
|
+
* validator calls the parser, so the two cannot disagree.
|
|
14
|
+
* - A value is valid only against its code: `"202406151430"` is a `DT` value and not an `RTS`
|
|
15
|
+
* one.
|
|
16
|
+
* - Checks the calendar as well as the shape: 31 June, 29 February 2023, hour 24 and second 60
|
|
17
|
+
* are false.
|
|
18
|
+
* - False for any other code, a code of another kind included; check a code alone with
|
|
19
|
+
* `isValidX12DateTimePeriodFormat`. False for a non-string argument.
|
|
20
|
+
*
|
|
21
|
+
* @param value The data element 1251 value (e.g. "202406151430")
|
|
22
|
+
* @param format X12 data element 1250 format qualifier
|
|
23
|
+
* @returns boolean indicating validity
|
|
24
|
+
*
|
|
25
|
+
* @example isValidX12DateTime("202406151430", "DT") // true
|
|
26
|
+
* @example isValidX12DateTime("20240615143045", "RTS") // true
|
|
27
|
+
* @example isValidX12DateTime("202406151430", "RTS") // false (twelve digits is a DT value)
|
|
28
|
+
* @example isValidX12DateTime("202406152430", "DT") // false (hour 24)
|
|
29
|
+
*/
|
|
30
|
+
export function isValidX12DateTime(value, format) {
|
|
31
|
+
return parseX12DateTime(value, format) !== "";
|
|
32
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { X12DateTimePeriodFormat } from "../../types/edi.js";
|
|
2
|
+
/**
|
|
3
|
+
* Return true when `format` is an X12 data element 1250 (Date Time Period Format Qualifier) code
|
|
4
|
+
* that the X12 functions read and write.
|
|
5
|
+
*
|
|
6
|
+
* - The 10 supported codes are `D8`, `DB` (a date); `TM`, `TS` (a time); `DT`, `RTS` (a date and
|
|
7
|
+
* time); `RD8`, `RD` (a range of dates) and `RDT`, `DTS` (a range of date-times).
|
|
8
|
+
* `classifyX12DateTimePeriodFormat` names the kind of a code, and each kind has its own
|
|
9
|
+
* parser, formatter and validator. Release 005010, read from
|
|
10
|
+
* [Stedi's X12-licensed dictionary](https://www.stedi.com/edi/x12-005010/element/1250); the
|
|
11
|
+
* X12 text itself was not reached. The 42-code list is the same in release 008010.
|
|
12
|
+
* - A code with a two-digit year returns false: `D6`, `TT`, `TR`, `RD6` and `TU`. X12 does not
|
|
13
|
+
* say which century `YY` belongs to; read such a value with `parseDateWithPattern` or
|
|
14
|
+
* `parseDateTimeWithPattern`, a `yy` pattern and its `yearWindow` option.
|
|
15
|
+
* - `TC` and `EH` (a day of the year with no whole year), `DDT` and `DTD` (a range with a date on
|
|
16
|
+
* one side and a date-time on the other), `RTM` (a range of times with no date) and `UN`
|
|
17
|
+
* (Unstructured) return false: none states a value of one kind.
|
|
18
|
+
* - The other 21 codes of the element return false: the partial values (`CC`, `CY`, `CM`, `CQ`,
|
|
19
|
+
* `YM`, `MD`, `DD`, `MM`, `TQ`, `YY`, `MCY`), the ranges of partial values (`DA`, `RD2`, `RD4`,
|
|
20
|
+
* `RD5`, `RMD`, `RMY`), `RDM` (`YYMMDD-MMDD`, a range whose end names no year) and the
|
|
21
|
+
* month-name forms (`CD`, `KA`, `YMM`).
|
|
22
|
+
* - `TS`, `TT`, `CD` and `MD` are codes of data element 623 (Time Code) too, with unrelated
|
|
23
|
+
* meanings: here `TS` is `HHMMSS`, and `TT`, `CD` and `MD` are not read; there they name the
|
|
24
|
+
* Atlantic, Central and Mountain zones. Check a time code with `isValidX12TimeCode`.
|
|
25
|
+
* - Matching is exact: case and spacing are not normalised.
|
|
26
|
+
* - Accepts any input type and returns false for non-string values.
|
|
27
|
+
* - A parser returns its sentinel for a code it does not read and for a bad value alike. Check
|
|
28
|
+
* the code here to tell a code GMT does not read apart from a value that does not fit its
|
|
29
|
+
* code.
|
|
30
|
+
*
|
|
31
|
+
* @param format candidate value of any type
|
|
32
|
+
* @returns boolean indicating validity
|
|
33
|
+
*
|
|
34
|
+
* @example isValidX12DateTimePeriodFormat("D8") // true
|
|
35
|
+
* @example isValidX12DateTimePeriodFormat("RD8") // true
|
|
36
|
+
* @example isValidX12DateTimePeriodFormat("D6") // false (a two-digit year: not read)
|
|
37
|
+
* @example isValidX12DateTimePeriodFormat("UN") // false (unstructured: nothing to read)
|
|
38
|
+
* @example isValidX12DateTimePeriodFormat("d8") // false (case is exact)
|
|
39
|
+
* @example isValidX12DateTimePeriodFormat("CM") // false (a year and month: a code GMT does not read)
|
|
40
|
+
* @example isValidX12DateTimePeriodFormat("DTM") // false (a segment name, not a 1250 code)
|
|
41
|
+
* @example isValidX12DateTimePeriodFormat(null) // false
|
|
42
|
+
*/
|
|
43
|
+
export declare function isValidX12DateTimePeriodFormat(format: unknown): format is X12DateTimePeriodFormat;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { X12_DATE_TIME_PERIOD_FORMATS } from "../../internal/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Return true when `format` is an X12 data element 1250 (Date Time Period Format Qualifier) code
|
|
4
|
+
* that the X12 functions read and write.
|
|
5
|
+
*
|
|
6
|
+
* - The 10 supported codes are `D8`, `DB` (a date); `TM`, `TS` (a time); `DT`, `RTS` (a date and
|
|
7
|
+
* time); `RD8`, `RD` (a range of dates) and `RDT`, `DTS` (a range of date-times).
|
|
8
|
+
* `classifyX12DateTimePeriodFormat` names the kind of a code, and each kind has its own
|
|
9
|
+
* parser, formatter and validator. Release 005010, read from
|
|
10
|
+
* [Stedi's X12-licensed dictionary](https://www.stedi.com/edi/x12-005010/element/1250); the
|
|
11
|
+
* X12 text itself was not reached. The 42-code list is the same in release 008010.
|
|
12
|
+
* - A code with a two-digit year returns false: `D6`, `TT`, `TR`, `RD6` and `TU`. X12 does not
|
|
13
|
+
* say which century `YY` belongs to; read such a value with `parseDateWithPattern` or
|
|
14
|
+
* `parseDateTimeWithPattern`, a `yy` pattern and its `yearWindow` option.
|
|
15
|
+
* - `TC` and `EH` (a day of the year with no whole year), `DDT` and `DTD` (a range with a date on
|
|
16
|
+
* one side and a date-time on the other), `RTM` (a range of times with no date) and `UN`
|
|
17
|
+
* (Unstructured) return false: none states a value of one kind.
|
|
18
|
+
* - The other 21 codes of the element return false: the partial values (`CC`, `CY`, `CM`, `CQ`,
|
|
19
|
+
* `YM`, `MD`, `DD`, `MM`, `TQ`, `YY`, `MCY`), the ranges of partial values (`DA`, `RD2`, `RD4`,
|
|
20
|
+
* `RD5`, `RMD`, `RMY`), `RDM` (`YYMMDD-MMDD`, a range whose end names no year) and the
|
|
21
|
+
* month-name forms (`CD`, `KA`, `YMM`).
|
|
22
|
+
* - `TS`, `TT`, `CD` and `MD` are codes of data element 623 (Time Code) too, with unrelated
|
|
23
|
+
* meanings: here `TS` is `HHMMSS`, and `TT`, `CD` and `MD` are not read; there they name the
|
|
24
|
+
* Atlantic, Central and Mountain zones. Check a time code with `isValidX12TimeCode`.
|
|
25
|
+
* - Matching is exact: case and spacing are not normalised.
|
|
26
|
+
* - Accepts any input type and returns false for non-string values.
|
|
27
|
+
* - A parser returns its sentinel for a code it does not read and for a bad value alike. Check
|
|
28
|
+
* the code here to tell a code GMT does not read apart from a value that does not fit its
|
|
29
|
+
* code.
|
|
30
|
+
*
|
|
31
|
+
* @param format candidate value of any type
|
|
32
|
+
* @returns boolean indicating validity
|
|
33
|
+
*
|
|
34
|
+
* @example isValidX12DateTimePeriodFormat("D8") // true
|
|
35
|
+
* @example isValidX12DateTimePeriodFormat("RD8") // true
|
|
36
|
+
* @example isValidX12DateTimePeriodFormat("D6") // false (a two-digit year: not read)
|
|
37
|
+
* @example isValidX12DateTimePeriodFormat("UN") // false (unstructured: nothing to read)
|
|
38
|
+
* @example isValidX12DateTimePeriodFormat("d8") // false (case is exact)
|
|
39
|
+
* @example isValidX12DateTimePeriodFormat("CM") // false (a year and month: a code GMT does not read)
|
|
40
|
+
* @example isValidX12DateTimePeriodFormat("DTM") // false (a segment name, not a 1250 code)
|
|
41
|
+
* @example isValidX12DateTimePeriodFormat(null) // false
|
|
42
|
+
*/
|
|
43
|
+
export function isValidX12DateTimePeriodFormat(format) {
|
|
44
|
+
return (typeof format === "string" &&
|
|
45
|
+
X12_DATE_TIME_PERIOD_FORMATS.includes(format));
|
|
46
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { X12DateTimeRangeFormat } from "../../types/edi.js";
|
|
2
|
+
/**
|
|
3
|
+
* Return true when `value` is an X12 Date Time Period value (data element 1251) that states a
|
|
4
|
+
* range between two real local date-times, in a date-time range format qualifier (data element
|
|
5
|
+
* 1250).
|
|
6
|
+
*
|
|
7
|
+
* ### Format codes
|
|
8
|
+
* | Code | Mask | The dictionary's definition |
|
|
9
|
+
* |---|---|---|
|
|
10
|
+
* | `RDT` | `CCYYMMDDHHMM-CCYYMMDDHHMM` | "Range of Date and Time, Expressed in Format CCYYMMDDHHMM-CCYYMMDDHHMM" |
|
|
11
|
+
* | `DTS` | `CCYYMMDDHHMMSS-CCYYMMDDHHMMSS` | "Range of Date and Time Expressed in Format CCYYMMDDHHMMSS-CCYYMMDDHHMMSS" |
|
|
12
|
+
*
|
|
13
|
+
* - True exactly when `parseX12DateTimeRange` returns a range for the same arguments: the
|
|
14
|
+
* validator calls the parser, so the two cannot disagree.
|
|
15
|
+
* - A range is valid with exactly one hyphen, and only against its code.
|
|
16
|
+
* - A range whose end precedes its start is false; an end equal to its start is true.
|
|
17
|
+
* - Checks the calendar as well as the shape: hour 24, second 60 and 29 February 2023 are
|
|
18
|
+
* false.
|
|
19
|
+
* - False for any other code, a code of another kind included; check a code alone with
|
|
20
|
+
* `isValidX12DateTimePeriodFormat`. False for a non-string argument.
|
|
21
|
+
*
|
|
22
|
+
* @param value The data element 1251 value (e.g. "202406151430-202406201600")
|
|
23
|
+
* @param format X12 data element 1250 format qualifier
|
|
24
|
+
* @returns boolean indicating validity
|
|
25
|
+
*
|
|
26
|
+
* @example isValidX12DateTimeRange("202406151430-202406201600", "RDT") // true
|
|
27
|
+
* @example isValidX12DateTimeRange("20240615143045-20240620160030", "DTS") // true
|
|
28
|
+
* @example isValidX12DateTimeRange("202406151430202406201600", "RDT") // false (a range is transmitted with its hyphen)
|
|
29
|
+
* @example isValidX12DateTimeRange("202406151431-202406151430", "RDT") // false (the end precedes the start)
|
|
30
|
+
*/
|
|
31
|
+
export declare function isValidX12DateTimeRange(value: string, format: X12DateTimeRangeFormat): boolean;
|