formatEdifactOffsetDateTime
Signature
Section titled “Signature”formatEdifactOffsetDateTime(value: string, format: EdifactOffsetDateTimeFormat): stringWrite an ISO 8601 date-time with an offset as a UN/EDIFACT DTM value (data element 2380) in a format code that carries an offset (data element 2379). The inverse of parseEdifactOffsetDateTime.
-
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 205CCYYMMDDHHMMZHHMM“Calendar date including time and time zone expressed in hours and minutes.” 208CCYYMMDDHHMMSSZHHMM“Calendar date including time with seconds, with Time Zone” (D.12A and later) 303CCYYMMDDHHMMZZZ“See 203 plus Z=Time zone.” 304CCYYMMDDHHMMSSZZZ“See 204 plus Z=Time zone.” -
valueis an ISO 8601 date-time with an offset (2024-06-15T14:30:00+02:00) or aZinstant, astoOffsetInstantreads it: the stringparseEdifactOffsetDateTimereturns andfromOffsetInstantwrites. A local date-time, a date and a time return"": there is no offset to write. -
The digits are the value’s own wall clock, never the UTC clock:
2024-01-01T00:30:00+02:00under303is202401010030+02. AZinstant is written on the UTC clock with+0000or+00. -
ZZZ(303,304) is always written±HH, the hours-only form of UN/ECE Recommendation 7 ¶12, neverUTCorGMT. It holds whole hours only: an offset such as+05:30returns""under303and304. Write it under205or208, whoseZHHMMholds hours and minutes. -
An offset with a non-zero seconds part returns
""under every code,205and208included. A seconds part of zero (+02:00:00) is the offset+02:00and is written.ZHHMMholds hours and minutes andZZZhours, so no mask holds the seconds of an offset such as-00:44:30, the offsetAfrica/Monroviakept until 1972. An offset is never rounded: the value would name another instant. Write the same instant inZform instead. -
Precision is cut to the mask, never rounded: a fraction of a second is always dropped, and
205and303drop the seconds too. -
The output is the element value, not segment text.
+is the EDIFACT data element separator, so a value that holds one must be released when it is placed in a segment: write?+. The function does not add the release character. -
A bracketed RFC 9557 time zone is read as
toOffsetInstantreads it: it must agree with the offset, and besideZit sets the clock the digits are written on. -
A wall clock whose year is outside 0000–9999 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 |
|---|---|---|
value | string | ISO 8601 date-time with an offset or Z (e.g. “2024-06-15T14:30:00+02:00”) |
format | EdifactOffsetDateTimeFormat | The data element 2379 format code |
Returns
Section titled “Returns”the data element 2380 value, unescaped, or "" on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”import { formatEdifactOffsetDateTime } from "@northguild/gmt/intermodal/format";
formatEdifactOffsetDateTime("2024-06-15T14:30:00+02:00", "205") // "202406151430+0200"