parseEdifactDateTimePeriod
Signature
Section titled “Signature”parseEdifactDateTimePeriod(value: string, format: "719"): EdiDateTimePeriod | nullParse a UN/EDIFACT DTM value that states a period between two local date-times, as its start and end.
-
A
DTMsegment carries its value in data element 2380 and, in data element 2379, the format code that says how to read it. The mask and description are the UNTDID directory’s, read from UNECE’s D.21B page as archived. ### Format codeCode Mask The directory’s description 719CCYYMMDDHHMM-CCYYMMDDHHMM“A period of time which includes the century, year, month, day, hour and minute. Format of period to be given in actual message without hyphen.” -
A period is transmitted without a hyphen, and a hyphen is rejected. The hyphen in the mask is notation:
"202406151430202406201600"reads and"202406151430-202406201600"returnsnull. -
startandendare local date-times as transmitted, eachYYYY-MM-DDTHH:MM:SSwith seconds00. The code carries no offset, so neither names an instant: pass each and the place’s IANA zone toresolveLocal. -
The directory does not say whether the end is inside the period. Pass the pair to the plain interval functions as
(start, end), for exampleintervalLengthDateTime(period.start, period.end, "hours"); they leaveendoutside the interval. -
An end before its start returns
null: a reversed period names no span of time. An end equal to its start is a valid period. -
Fields are checked, not clamped: hour 24, minute 60 and 29 February 2023 return
null. -
A two-digit year (
713,YYMMDDHHMM-YYMMDDHHMM) is not read. Split such a value in two and read each half withparseDateTimeWithPattern, ayypattern and itsyearWindowoption. -
Returns
nullfor any other code, a code of another kind included (718is read byparseEdifactDatePeriod), and for a non-string argument.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | The data element 2380 value (e.g. “202406151430202406201600”) |
format | "719" | The data element 2379 format code |
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 { parseEdifactDateTimePeriod } from "@northguild/gmt/intermodal/parse";
parseEdifactDateTimePeriod("202406151430202406201600", "719") // { start: "2024-06-15T14:30:00", end: "2024-06-20T16:00:00" }