formatX12Time
Signature
Section titled “Signature”formatX12Time(value: string, format: X12TimeFormat): stringWrite an ISO 8601 time as an X12 time in a time format qualifier (data element 1250). The result is also a data element 337 (Time) value: parseX12Time reads it back with the same qualifier, and with none.
-
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 TMHHMM“Time Expressed in Format HHMM” TSHHMMSS“Time Expressed in Format HHMMSS” -
valueis a time, asisValidTimeaccepts it:HH:MM, with seconds and a fraction of a second if it has them. A date-time, a date or a time with an offset returns"". -
Precision is cut to the mask, never rounded: a fraction of a second is always dropped, and
TMdrops the seconds too.14:30:45.123is1430underTMand143045underTS. -
To write the time element of a freight segment (
AT7-06,G62-04,DTM-03), useformatX12TimeElement: it writes all four forms of data element 337, named by the element’s own masks, tenths and hundredths of a second included.TMandTSgive the same digits as that element’sHHMMandHHMMSSforms, and no 1250 code holds decimal seconds. -
TShere is the formatHHMMSS. As a data element 623 time code,TSis Atlantic Standard Time: read that withx12TimeCodeZone. -
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 time (e.g. “14:30:00”) |
format | X12TimeFormat | X12 data element 1250 format qualifier |
Returns
Section titled “Returns”the X12 time value, or "" on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”import { formatX12Time } from "@northguild/gmt/intermodal/format";
formatX12Time("14:30:00", "TM") // "1430"