x12TimeCodeOffset
Signature
Section titled “Signature”x12TimeCodeOffset(timeCode: X12OffsetTimeCode): stringRead the UTC offset an X12 time code (data element 623) states.
-
Data element 623 is the code beside the date (element 373) and time (element 337) of an X12
AT7,G62orDTMsegment, and the only thing in the segment that says where the clock was. 31 of its 56 codes state an offset; this function reads those. The element’s own definition: “Code identifying the time. In accordance with International Standards Organization standard 8601, time can be specified by a + or - and an indication in hours in relation to Universal Time Coordinate (UTC) time; since + is a restricted character, + and - are substituted by P and M in the codes that follow”. Codes are release 008010, read from Stedi’s X12-licensed dictionary; the X12 text itself was not reached. ### Time codes that state an offsetCodes The dictionary’s definition Offset 01–12“Equivalent to ISO P01” … “P12” +01:00…+12:0013–24“Equivalent to ISO M12” … “M01” -12:00…-01:00, counting down25–29“Equivalent to ISO M2:30”, “M3:30”, “P5:30”, “P9:30”, “P10:30” -02:30,-03:30,+05:30,+09:30,+10:30UT“Universal Time Coordinate” +00:00GM“Greenwich Mean Time” +00:00 -
13–24count down:13is-12:00and24is-01:00. The code rises as the offset nears UTC, so20is-05:00. -
25–29were added in release 006010 and are not valid in an 004010 or 005010 interchange. The function takes no release, so it reads them. -
GMis+00:00by a GMT rule, not by X12’s statement. X12 defines it only by the name “Greenwich Mean Time”. UN/ECE Recommendation 7 ¶12 names one scale by both names, “Co-ordinated Universal Time (formerly known as Greenwich Mean Time)”, so GMT readsGMas UTC. -
A named code returns
"": X12 states no offset forET,ES,PDorLT, and GMT holds no table of zone offsets. Read one withx12TimeCodeZone. -
To get the instant, resolve the segment’s local date-time at the offset:
resolveLocal(parseX12DateAndTime("20240615", "1430"), x12TimeCodeOffset("20"))is"2024-06-15T19:30:00Z". -
For a code that arrives as a string, call
classifyX12TimeCodefirst: its"offset"result carries the code narrowed to this function’s parameter. -
Matching is exact: two characters, upper case, no padding. Returns
""for a code that is not one of the 56 and for a non-string. UseisValidX12TimeCodeto check a code.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
timeCode | X12OffsetTimeCode | X12 data element 623 time code (e.g. “20”) |
Returns
Section titled “Returns”the offset as ±HH:MM, or "" on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”import { x12TimeCodeOffset } from "@northguild/gmt/intermodal/parse";
x12TimeCodeOffset("20") // "-05:00"