Skip to content

X12 Time Reader

  • Container free time, demurrage, billing deadlines, bill of lading dates and EDI timestamps.

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.

1. The date, the time and the time code

ET names a zone and says neither standard nor daylight. X12 states no offset for it, so the instant needs an IANA zone. This example reads it in two places on Eastern time: America/New_York, which is on daylight time on this June date, and America/Atikokan in Ontario, which keeps standard time all year. They are an hour apart, so the name alone does not fix the offset. Both zones are the example's picks, not something X12 or the code says: pick the zone your message means.

Element 373 is CCYYMMDD. Element 337 is HHMM, HHMMSS, HHMMSSD or HHMMSSDD. Any of the three may be empty, and an empty element is left out of the call.

2. What the calls return

Kind
no result
Value
no result
Time code
no result
Offset
no result
Zone name
no result
Daylight
no result
Instant
no result
 

3. The instant, and where the same digits land

1
2
3
4

 

4. Written back by formatX12Date and formatX12TimeElement

The date as element 373, with D8.

 

The time as element 337, in the form it was sent.

 

5. A DTP value

A range of dates is sent with a hyphen between its two ends. It names no instant, and a qualifier has no time code.

A DTP segment carries a 1250 qualifier and an element 1251 value. It carries no time code, and no 1250 code states an offset.

6. What the DTP calls return

Kind
no result
Value
no result
Range end
no result
 
 

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.