formatX12Date
Signature
Section titled “Signature”formatX12Date(value: string, format: X12DateFormat): stringWrite an ISO 8601 date as an X12 Date Time Period value (data element 1251) in a date format qualifier (data element 1250). The inverse of parseX12Date.
-
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 D8CCYYMMDD“Date Expressed in Format CCYYMMDD” DBMMDDCCYY“Date Expressed in Format MMDDCCYY” -
valueis a date, asisValidDateaccepts it. A date-time, an instant or a time returns"", asformatDatereturns""for them: pass the date alone. -
Each field is zero-padded to the width the mask gives it.
-
D8also writes data element 373 (Date), theCCYYMMDDdate element ofAT7,G62andDTM-02. -
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 date (e.g. “2024-06-15”) |
format | X12DateFormat | 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 { formatX12Date } from "@northguild/gmt/intermodal/format";
formatX12Date("2024-06-15", "D8") // "20240615"