formatEdifactDateTimePeriod
Signature
Section titled “Signature”formatEdifactDateTimePeriod(start: string, end: string, format: "719"): stringWrite two ISO 8601 local date-times as a UN/EDIFACT DTM period (data element 2380) in a date-time period format code (data element 2379). The inverse of parseEdifactDateTimePeriod.
-
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 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.” -
startandendare local date-times, asisValidDateTimeaccepts them: the two membersparseEdifactDateTimePeriodreturns. A date, an instant ending inZand a date-time with an offset return"": the code holds no offset. -
The period is written without a hyphen: 15 June 14:30 to 20 June 16:00 is
202406151430202406201600. -
Precision is cut to the mask, never rounded: seconds and a fraction of a second are dropped from both ends.
-
An end before its start returns
"": a reversed period names no span of time. The ends are compared as given, before either is cut to the minute. An end equal to its start is written. -
A year outside 0000–9999 in either end 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 local date-time the period starts at (e.g. “2024-06-15T14:30:00”) |
end | string | ISO 8601 local date-time the period ends at (e.g. “2024-06-20T16:00:00”) |
format | "719" | 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 { formatEdifactDateTimePeriod } from "@northguild/gmt/intermodal/format";
formatEdifactDateTimePeriod("2024-06-15T14:30:00", "2024-06-20T16:00:00", "719") // "202406151430202406201600"