formatEdifactDateTime
Signature
Section titled “Signature”formatEdifactDateTime(value: string, format: EdifactDateTimeFormat): stringWrite an ISO 8601 local date-time as a UN/EDIFACT DTM value (data element 2380) in a format code with no offset (data element 2379). The inverse of parseEdifactDateTime.
-
Masks and descriptions are the UNTDID directory’s, read from UNECE’s D.21B page as archived. ### Format codes
Code Mask The directory’s description 203CCYYMMDDHHMM“Calendar date including time with minutes” 204CCYYMMDDHHMMSS“Calendar date including time with seconds” -
valueis a local date-time, asisValidDateTimeaccepts it. A date, a time, an instant ending inZand a date-time with an offset return"": these codes hold no offset. Write an instant withformatEdifactOffsetDateTime. -
Precision is cut to the mask, never rounded: a fraction of a second is always dropped, and
203drops the seconds too.2024-06-15T14:30:45.9is202406151430under203and20240615143045under204. -
A year outside 0000–9999 returns
"":CCYYis four digits and no sign. -
Returns
""for any other code, a code of another kind included, and for a non-string argument.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | ISO 8601 local date-time (e.g. “2024-06-15T14:30:00”) |
format | EdifactDateTimeFormat | 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 { formatEdifactDateTime } from "@northguild/gmt/intermodal/format";
formatEdifactDateTime("2024-06-15T14:30:00", "203") // "202406151430"