X12 Time Reader
X12 sends one point in time as three elements: a date (373), a time (337) and a time code (623). Type them, and the tool takes them apart and says what they state. A second section reads a DTP value. The one thing to know is that the date and the time carry no offset, so the time code is the only thing that says where the clock was: parseX12DateAndTime reads the date and the time, classifyX12TimeCode classifies the code, and everything on the page is what those calls returned.
The three elements. X12 is a United States standard. The 214’s AT7, the 204’s G62 and DTM carry the date, the time and the time code side by side. Any of the three may be empty. The tool reads a date and a time together with parseX12DateAndTime, and a date or a time sent alone with parseX12Date or parseX12Time.
What a time code states. It states an offset, as 01 does for UTC+1 and 13 does for UTC−12. It names a zone and states no offset, as ET does. Or it says local to the event, as LT does, and so does a blank code, because the place is elsewhere in the message. The verdict has two forms: the offset is stated, and the instant comes from resolveLocal(local, offset); or it is not stated, and the instant comes from the zones you pick.
Why the zones are yours. The library maps no time code, place or partner to a zone. Each preset that states no offset opens with the zones its example picked, and those are the example’s choice, not something X12 or the code says. Typing a time code never fills a zone, and the tool does not check a daylight flag against the zone you pick. Each row calls resolveLocal with disambiguation: "reject", so a time the clock shows twice or never is not resolved, and the row says why.
A DTP value. A DTP carries a 1250 qualifier and an element 1251 value. It has no time code and no instant, and the tool classifies the qualifier with classifyX12DateTimePeriodFormat and calls the parser of the kind that came back. A two-digit-year qualifier such as D6 is not read: the sentence under NO SIGNAL names the pattern parser and the yearWindow that read it.
Worth trying: ET with America/New_York picked —
then change the date to January and watch the instant move an hour. Then code 13 —
the offset is UTC−12, not UTC−1, and the instant is on the next UTC day. Type 24 to see UTC−1.
Reference: parseX12DateAndTime reads the
date and the time, x12TimeCodeOffset and
x12TimeCodeZone say what the code states, and
the classifiers tell a code from an abbreviation when a read is refused.
formatX12Date and
formatX12TimeElement write the date and the
time back, the time in the form it was sent.
resolveLocal,
toOffsetInstant and
fromOffsetInstant turn a local time into an
instant, and diffUtcAsDuration states the gap
between the zones. The rules are in
Intermodal: EDI Timestamps.