parseEpcisEvent
Signature
Section titled “Signature”parseEpcisEvent(event: EpcisEventTime): EpcisInstant | nullRead the two required time fields of a GS1 EPCIS 2.0 event as an instant, the UTC offset in force where the event happened, and the local wall clock there.
- EPCIS (ISO/IEC 19987) is GS1’s event standard for supply-chain visibility: each event records what happened to which objects, where, when and why.
- Both fields are required, as the EPCIS JSON schema requires them.
eventTimefixes the instant.eventTimeZoneOffsetis the offset the local clock ran at where the event happened, kept so the event can be shown in local time. Neither derives from the other, so an event withouteventTimeZoneOffsetreturns null: UTC is not assumed. - Each field is checked against the stricter of the two bindings.
eventTimetakes the XML binding’s pattern (the XSD’sDateTimeStamp; the JSON schema says onlyformat: date-time).eventTimeZoneOffsettakes the JSON schema’s pattern (the XSD types it as a barexsd:string), which is the rule the standard states in prose, EPCIS Standard Release 2.0 §7.4.1 (https://ref.gs1.org/standards/epcis/): an hour “within the range 00 through 14 (inclusive) … except that if the value of the first two digits is 14, the value of the second two digits must be 00”. eventTimemust matchepcisEventTime, theDateTimeStamppattern of the EPCIS XSD:YYYY-MM-DDTHH:MM:SS, an optional fraction, thenZor a±HH:MMoffset up to14:00. Seconds are required,TandZare upper-case, and nothing may follow: a space separator, a leap second (:60), an expanded year and a bracketed zone or annotation return null. The pattern checks shape only, so a day the month does not have (2024-02-30) is rejected by Temporal and returns null.eventTimeZoneOffsetmust matchepcisTimeZoneOffset, the pattern the EPCIS JSON schema gives:±HH:MMfrom-14:00to+14:00.Z,+0200,+02and an offset with seconds return null.- The two fields are independent and need not agree.
eventTimemay carry an offset of its own instead ofZ; that offset only fixes the instant. The local clock always comes fromeventTimeZoneOffset, and a difference between the two is not an error. EPCIS 2.0 §7.4.1.1, an explanation the standard marks non-normative: “there is no requirement that the time zone specifier in the XML representation of eventTime be the local time zone offset where the event was captured”. - An instant can fall outside years 0000–9999. An
eventTimewhose own offset carries it across either end of the four-digit years names an instant just past it, written with a sign and a six-digit year, andlocalis written the same way when it falls outside. -00:00matches the GS1 pattern and is returned as+00:00, astoOffsetInstantreturns it. RFC 9557 §2.2 reads-00:00as “local offset unknown”; the result cannot say that.- GMT rule: a fraction longer than nine digits returns null. The XSD allows a fraction of any length and an instant holds nanoseconds. Dropping digits would report a time the event does not state, so the value is refused instead, trailing zeros included.
localis the instant shown at the offset, so its date can differ from the UTC date.- Only the two fields are read.
recordTimeand every other member of the event are ignored. - Returns null when
eventis not an object, when either field is missing or not a string, and for every case above.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
event | EpcisEventTime | an EPCIS event, or any object with its eventTime and eventTimeZoneOffset |
Returns
Section titled “Returns”{ instant, offset, local }, or null on invalid input
EpcisInstant
Section titled “EpcisInstant”When a GS1 EPCIS 2.0 event happened, read three ways: the instant, the UTC offset in force where it happened, and the local wall clock there. The result of parseEpcisEvent.
import type { EpcisInstant } from "@northguild/gmt";| Member | Type | Description |
|---|---|---|
instant | string | The moment the event happened, as an ISO 8601 instant in UTC ending in Z (2024-06-15T14:30:00Z). It orders events from every site on one timeline. A fraction is kept to the nanosecond and written without trailing zeros. An eventTime whose own offset carries it across either end of years 0000–9999 gives an instant with a sign and a six-digit year. |
offset | string | The UTC offset in force where the event happened, ±HH:MM: the event’s eventTimeZoneOffset, with -00:00 written as +00:00. It is an offset and not a zone, so it says nothing about the local time of any other event. |
local | string | The date and time on the local clock where the event happened, YYYY-MM-DDTHH:MM:SS[.fraction] with no offset: instant shown at offset. Its date can be the day before or after the UTC date. A year outside 0000–9999, reachable only within 14 hours of either end of the four-digit range, is written with a sign and six digits. |
Related types
Section titled “Related types”Examples
Section titled “Examples”import { parseEpcisEvent } from "@northguild/gmt/intermodal/parse";
parseEpcisEvent({ eventTime: "2024-06-15T14:30:00Z", eventTimeZoneOffset: "-05:00" }) // { instant: "2024-06-15T14:30:00Z", offset: "-05:00", local: "2024-06-15T09:30:00" }