Skip to content

formatX12Time

  • Container free time, demurrage, billing deadlines, bill of lading dates and EDI timestamps.
formatX12Time(value: string, format: X12TimeFormat): string

Write 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

    CodeMaskThe dictionary’s definition
    TMHHMM“Time Expressed in Format HHMM”
    TSHHMMSS“Time Expressed in Format HHMMSS”
  • value is a time, as isValidTime accepts 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 TM drops the seconds too. 14:30:45.123 is 1430 under TM and 143045 under TS.

  • To write the time element of a freight segment (AT7-06, G62-04, DTM-03), use formatX12TimeElement: it writes all four forms of data element 337, named by the element’s own masks, tenths and hundredths of a second included. TM and TS give the same digits as that element’s HHMM and HHMMSS forms, and no 1250 code holds decimal seconds.

  • TS here is the format HHMMSS. As a data element 623 time code, TS is Atlantic Standard Time: read that with x12TimeCodeZone.

  • Returns "" for any other code, a code of another kind included, and for a non-string argument.

ParameterTypeDescription
valuestringISO 8601 time (e.g. “14:30:00”)
formatX12TimeFormatX12 data element 1250 format qualifier

the X12 time value, or "" on invalid input

import { formatX12Time } from "@northguild/gmt/intermodal/format";
formatX12Time("14:30:00", "TM") // "1430"
output 

intermodal/format/formatX12Time.ts