formatX12DateTime
Signature
Section titled “Signature”formatX12DateTime(value: string, format: X12DateTimeFormat): stringWrite an ISO 8601 local date-time as an X12 Date Time Period value (data element 1251) in a date-time format qualifier (data element 1250). The inverse of parseX12DateTime.
-
Codes are release 005010, read from Stedi’s X12-licensed dictionary; the X12 text itself was not reached. ### Format codes
Code Mask The dictionary’s definition DTCCYYMMDDHHMM“Date and Time Expressed in Format CCYYMMDDHHMM” RTSCCYYMMDDHHMMSS“Date and Time Expressed in Format CCYYMMDDHHMMSS” -
valueis a local date-time, asisValidDateTimeaccepts it. A date and a time return"". -
No 1250 code carries an offset, so an instant ending in
Zand a date-time with an offset return"": an instant is not written as a wall clock. Pass the local date-time. -
Precision is cut to the mask, never rounded: a fraction of a second is always dropped, and
DTdrops the seconds too.2024-06-15T14:30:45.9is202406151430underDTand20240615143045underRTS. -
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 | X12DateTimeFormat | X12 data element 1250 format qualifier |
Returns
Section titled “Returns”the data element 1251 value, or "" on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”import { formatX12DateTime } from "@northguild/gmt/intermodal/format";
formatX12DateTime("2024-06-15T14:30:00", "DT") // "202406151430"