formatEdifactDatePeriod
Signature
Section titled “Signature”formatEdifactDatePeriod(start: string, end: string, format: "718"): stringWrite two ISO 8601 dates as a UN/EDIFACT DTM period (data element 2380) in a date period format code (data element 2379). The inverse of parseEdifactDatePeriod.
-
The mask and description are the UNTDID directory’s, read from UNECE’s D.21B page as archived. ### Format code
Code Mask The directory’s description 718CCYYMMDD-CCYYMMDD“A period of time specified by giving the start date followed by the end date (both including century). Data is to be transmitted as consecutive characters without hyphen.” -
startandendare dates, asisValidDateaccepts them: the two membersparseEdifactDatePeriodreturns. A date-time or an instant returns"". -
The period is written without a hyphen, as every directory read says it is transmitted: 15 to 20 June 2024 is
2024061520240620. -
An end before its start returns
"": a reversed period names no span of time. An end equal to its start is written. -
A year outside 0000–9999 in either date returns
"". -
Returns
""for any other code, a code of another kind included, and for a non-string argument.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
start | string | ISO 8601 date the period starts on (e.g. “2024-06-15”) |
end | string | ISO 8601 date the period ends on (e.g. “2024-06-20”) |
format | "718" | The data element 2379 format code |
Returns
Section titled “Returns”the data element 2380 value, or "" on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”import { formatEdifactDatePeriod } from "@northguild/gmt/intermodal/format";
formatEdifactDatePeriod("2024-06-15", "2024-06-20", "718") // "2024061520240620"