bestAvailable
Signature
Section titled “Signature”bestAvailable(events: TimestampEvent[]): ClassifiedTimestamp | nullPick the best available timestamp for an event from its planned, estimated, requested and actual records, and say which class it is.
- One field often carries four meanings — DCSA’s
eventClassifierCodevocabulary:PLN(planned),EST(estimated),REQ(requested) andACT(actual). A dashboard that shows the latest-recorded value puts an estimate in the actual column the moment a late feed arrives. This returns the class with the value, so the consumer can label it. - An
ACTwins whenever there is one, whatever was recorded after it: an estimate recorded after the arrival is still only an estimate. - Otherwise
PLN, thenREQ, thenEST. ThisACT>PLN>REQ>ESTselection is GMT’s own convention. DCSA’s Port Call standard negotiates some port call services — a berth, pilotage, towage — through an estimated, then requested, then planned timestamp, followed by an actual; this order reads that pattern from its most settled end. DCSA defines the classes and the pattern, not a rule for choosing among them. A plan is agreed; a request is asked for; an estimate is only predicted. So anESTorREQnever replaces aPLN, however much later it was recorded, and there is never anESTwhen aREQexists. The order is fixed, not configurable. - Within the chosen class, the newest-recorded event wins (latest
recordedAt), so a revised plan or a corrected actual replaces the earlier one. Two records at the same instant go to the later one in the array. atis echoed exactly as written.atandrecordedAtare instants (Zor an offset) with no annotation of any kind, compared as instants: the offset fixes the instant. The choice keeps no zone, so a zoned string, a real zone bracket included, is invalid.- Returns
nullfor an empty list, or when any event is invalid — aclassifierother than exactlyPLN,EST,REQorACTincluded.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
events | TimestampEvent[] | the event’s timestamp records, in any order |
Returns
Section titled “Returns”the chosen at and its class (null for an empty list), or null on invalid input
ClassifiedTimestamp
Section titled “ClassifiedTimestamp”What bestAvailable returns: the chosen timestamp and the class it carries.
import type { ClassifiedTimestamp } from "@northguild/gmt";| Member | Type | Description |
|---|---|---|
at | string | The chosen event’s at, exactly as it was written. |
classifier | "PLN" | "EST" | "REQ" | "ACT" (TimestampClass) | The class of the chosen event, so the value is never shown as something it is not. |
Related types
Section titled “Related types”Examples
Section titled “Examples”import { bestAvailable } from "@northguild/gmt/transport/calculate";
bestAvailable([{ classifier: "ACT", at: "2024-06-15T12:52:00Z", recordedAt: "2024-06-15T12:53:00Z" }, { classifier: "EST", at: "2024-06-15T13:05:00Z", recordedAt: "2024-06-15T14:00:00Z" }]) // { at: "2024-06-15T12:52:00Z", classifier: "ACT" } (an estimate recorded after the actual never replaces it)Source
Section titled “Source”Accessibility
© 2026 NorthGuild · Licences
Code examples: MIT-0. Packages: MIT. Third-party data and components: their own licences, credited where they appear. Everything else: © 2026 NorthGuild, all rights reserved.