parseX12DateTimeRange
Signature
Section titled “Signature”parseX12DateTimeRange(value: string, format: X12DateTimeRangeFormat): EdiDateTimePeriod | nullParse an X12 Date Time Period value that states a range between two local date-times, as its start and end.
-
A
DTPsegment carries a format qualifier inDTP-02(data element 1250) and its value inDTP-03(data element 1251);DTM-05andDTM-06carry the same pair. Codes are release 005010, read from Stedi’s X12-licensed dictionary; the X12 text itself was not reached. ### Format codesCode Mask The dictionary’s definition RDTCCYYMMDDHHMM-CCYYMMDDHHMM“Range of Date and Time, Expressed in Format CCYYMMDDHHMM-CCYYMMDDHHMM” DTSCCYYMMDDHHMMSS-CCYYMMDDHHMMSS“Range of Date and Time Expressed in Format CCYYMMDDHHMMSS-CCYYMMDDHHMMSS” -
A range is transmitted with exactly one hyphen:
"202406151430-202406201600"reads, and the same digits run together returnnull. -
startandendare local date-times as transmitted, eachYYYY-MM-DDTHH:MM:SS, with seconds00forRDT. No 1250 code carries an offset, so neither names an instant: pass each and the place’s IANA zone toresolveLocal. -
X12 does not say here whether the end is inside the range. Pass the pair to the plain interval functions as
(start, end), for exampleintervalLengthDateTime(range.start, range.end, "hours"); they leaveendoutside the interval. -
DTSis a range, despite having noR. -
An end before its start returns
null: a reversed range names no span of time. An end equal to its start is a valid range. -
Fields are checked, not clamped: hour 24, second 60 and 29 February 2023 return
null. -
A range with a date on one side and a date-time on the other (
DDT,DTD) is not read, and neither is a range of times with no date (RTM). -
Returns
nullfor any other code, a code of another kind included (RD8is read byparseX12DateRange), and for a non-string argument.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | The data element 1251 value (e.g. “202406151430-202406201600”) |
format | X12DateTimeRangeFormat | X12 data element 1250 format qualifier |
Returns
Section titled “Returns”{ start, end }, two ISO 8601 local date-times, or null on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”import { parseX12DateTimeRange } from "@northguild/gmt/intermodal/parse";
parseX12DateTimeRange("202406151430-202406201600", "RDT") // { start: "2024-06-15T14:30:00", end: "2024-06-20T16:00:00" }