@northguild/gmt 1.16.0 → 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +289 -8
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.js +2 -0
  4. package/dist/instant/convert/fromOffsetInstant.js +3 -11
  5. package/dist/instant/convert/toOffsetInstant.d.ts +23 -0
  6. package/dist/instant/convert/toOffsetInstant.js +2 -25
  7. package/dist/intermodal/calculate/billingTimeline.d.ts +94 -0
  8. package/dist/intermodal/calculate/billingTimeline.js +168 -0
  9. package/dist/intermodal/calculate/chargeableDays.d.ts +98 -0
  10. package/dist/intermodal/calculate/chargeableDays.js +101 -0
  11. package/dist/intermodal/calculate/demurrageClock.d.ts +93 -0
  12. package/dist/intermodal/calculate/demurrageClock.js +140 -0
  13. package/dist/intermodal/calculate/freeTimeExpiry.d.ts +66 -0
  14. package/dist/intermodal/calculate/freeTimeExpiry.js +82 -0
  15. package/dist/intermodal/calculate/index.d.ts +4 -0
  16. package/dist/intermodal/calculate/index.js +4 -0
  17. package/dist/intermodal/index.d.ts +2 -0
  18. package/dist/intermodal/index.js +3 -0
  19. package/dist/internal/freeTimeLedger.d.ts +93 -0
  20. package/dist/internal/freeTimeLedger.js +262 -0
  21. package/dist/internal/index.d.ts +4 -2
  22. package/dist/internal/index.js +4 -2
  23. package/dist/internal/isoStringBody.d.ts +26 -0
  24. package/dist/internal/isoStringBody.js +22 -2
  25. package/dist/internal/wallClockAtOffset.d.ts +22 -0
  26. package/dist/internal/wallClockAtOffset.js +26 -0
  27. package/dist/internal/zonedWallClockDifference.js +5 -4
  28. package/dist/transport/calculate/dwellTime.d.ts +72 -0
  29. package/dist/transport/calculate/dwellTime.js +126 -0
  30. package/dist/transport/calculate/index.d.ts +2 -0
  31. package/dist/transport/calculate/index.js +2 -0
  32. package/dist/transport/calculate/transitTime.d.ts +53 -0
  33. package/dist/transport/calculate/transitTime.js +118 -0
  34. package/dist/transport/convert/etaAtZone.d.ts +36 -0
  35. package/dist/transport/convert/etaAtZone.js +53 -0
  36. package/dist/transport/convert/index.d.ts +1 -0
  37. package/dist/transport/convert/index.js +1 -0
  38. package/dist/transport/index.d.ts +3 -0
  39. package/dist/transport/index.js +4 -0
  40. package/dist/types/free-time-options.d.ts +34 -0
  41. package/dist/types/free-time-options.js +0 -0
  42. package/dist/types/index.d.ts +1 -0
  43. package/dist/types/index.js +1 -0
  44. package/package.json +36 -1
  45. package/skills/gmt-arithmetic/SKILL.md +1 -1
  46. package/skills/gmt-basics/SKILL.md +1 -1
  47. package/skills/gmt-integration/SKILL.md +1 -1
  48. package/skills/gmt-timezone/SKILL.md +79 -12
@@ -14,6 +14,7 @@ export * from "./duration-string-options.js";
14
14
  export * from "./duration-unit.js";
15
15
  export * from "./fiscal-calendar.js";
16
16
  export * from "./fractional-digit.js";
17
+ export * from "./free-time-options.js";
17
18
  export * from "./interval.js";
18
19
  export * from "./now-unit.js";
19
20
  export * from "./offset.js";
@@ -14,6 +14,7 @@ export * from "./duration-string-options.js";
14
14
  export * from "./duration-unit.js";
15
15
  export * from "./fiscal-calendar.js";
16
16
  export * from "./fractional-digit.js";
17
+ export * from "./free-time-options.js";
17
18
  export * from "./interval.js";
18
19
  export * from "./now-unit.js";
19
20
  export * from "./offset.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@northguild/gmt",
3
- "version": "1.16.0",
3
+ "version": "1.17.0",
4
4
  "description": "Temporal-based date and time utilities with timezone support and polyfill integration",
5
5
  "keywords": [
6
6
  "date",
@@ -85,6 +85,12 @@
85
85
  "instant/convert": [
86
86
  "./dist/instant/convert/index.d.ts"
87
87
  ],
88
+ "intermodal": [
89
+ "./dist/intermodal/index.d.ts"
90
+ ],
91
+ "intermodal/calculate": [
92
+ "./dist/intermodal/calculate/index.d.ts"
93
+ ],
88
94
  "interval": [
89
95
  "./dist/interval/index.d.ts"
90
96
  ],
@@ -163,6 +169,15 @@
163
169
  "span/validate": [
164
170
  "./dist/span/validate/index.d.ts"
165
171
  ],
172
+ "transport": [
173
+ "./dist/transport/index.d.ts"
174
+ ],
175
+ "transport/calculate": [
176
+ "./dist/transport/calculate/index.d.ts"
177
+ ],
178
+ "transport/convert": [
179
+ "./dist/transport/convert/index.d.ts"
180
+ ],
166
181
  "types": [
167
182
  "./dist/types/index.d.ts"
168
183
  ],
@@ -315,6 +330,14 @@
315
330
  "types": "./dist/instant/convert/index.d.ts",
316
331
  "default": "./dist/instant/convert/index.js"
317
332
  },
333
+ "./intermodal": {
334
+ "types": "./dist/intermodal/index.d.ts",
335
+ "default": "./dist/intermodal/index.js"
336
+ },
337
+ "./intermodal/calculate": {
338
+ "types": "./dist/intermodal/calculate/index.d.ts",
339
+ "default": "./dist/intermodal/calculate/index.js"
340
+ },
318
341
  "./interval": {
319
342
  "types": "./dist/interval/index.d.ts",
320
343
  "default": "./dist/interval/index.js"
@@ -419,6 +442,18 @@
419
442
  "types": "./dist/span/validate/index.d.ts",
420
443
  "default": "./dist/span/validate/index.js"
421
444
  },
445
+ "./transport": {
446
+ "types": "./dist/transport/index.d.ts",
447
+ "default": "./dist/transport/index.js"
448
+ },
449
+ "./transport/calculate": {
450
+ "types": "./dist/transport/calculate/index.d.ts",
451
+ "default": "./dist/transport/calculate/index.js"
452
+ },
453
+ "./transport/convert": {
454
+ "types": "./dist/transport/convert/index.d.ts",
455
+ "default": "./dist/transport/convert/index.js"
456
+ },
422
457
  "./types": {
423
458
  "types": "./dist/types/index.d.ts",
424
459
  "default": "./dist/types/index.js"
@@ -32,7 +32,7 @@ sources:
32
32
  metadata:
33
33
  type: core
34
34
  library: '@northguild/gmt'
35
- library_version: '1.16.0'
35
+ library_version: '1.17.0'
36
36
  ---
37
37
 
38
38
  # GMT Arithmetic
@@ -24,7 +24,7 @@ sources:
24
24
  metadata:
25
25
  type: core
26
26
  library: '@northguild/gmt'
27
- library_version: '1.16.0'
27
+ library_version: '1.17.0'
28
28
  ---
29
29
 
30
30
  # GMT Basics
@@ -17,7 +17,7 @@ sources:
17
17
  metadata:
18
18
  type: composition
19
19
  library: '@northguild/gmt'
20
- library_version: '1.16.0'
20
+ library_version: '1.17.0'
21
21
  ---
22
22
 
23
23
  # GMT Integration
@@ -2,16 +2,20 @@
2
2
  name: gmt-timezone
3
3
  description: >
4
4
  Timezone-aware operations — get zoned now, format zoned datetimes/ranges,
5
- convert between plain↔zoned↔UTC↔Unix, DST disambiguation control on
6
- construction and arithmetic, the instant-plus-offset pair, classifying a
7
- zoneless wall time before resolving it, real zone unit boundaries
8
- (startOfZoned/endOfZoned/startOfUnix/endOfUnix, never after the input), hours
9
- in a local day, and flooring or bucketing instants on local calendar
10
- boundaries (floorToZone/bucketRange) instead of roundZoned, calendar-annotated
11
- zoned strings, and zoned values exact at the range limits (Australia/Sydney at
12
- the maximum, Etc/GMT+12 at the minimum). Reads the installed package README.md
13
- and source JSDoc for API details; this skill is a routing pointer, not an API
14
- dump.
5
+ convert between plain↔zoned↔UTC↔Unix, DST disambiguation on construction and
6
+ arithmetic, the instant-plus-offset pair, classifying a zoneless wall time
7
+ before resolving it, real zone unit boundaries
8
+ (startOfZoned/endOfZoned/startOfUnix/endOfUnix), hours in a local day,
9
+ flooring or bucketing on local boundaries (floorToZone/bucketRange),
10
+ calendar-annotated zoned strings, zoned values at the range limits, the
11
+ transport legs transitTime, etaAtZone and dwellTime (local calendar days
12
+ crossed), intermodal free time — freeTimeExpiry (the free window and its
13
+ half-open expiry), chargeableDays (the dates charged, with tier bands),
14
+ demurrageClock (which events a demurrage, detention, storage or combined clock
15
+ runs between) — and billingTimeline (invoice, dispute and resolution
16
+ deadlines, windows as caller parameters). Reads the installed package
17
+ README.md and source JSDoc for API details; this skill is a routing pointer,
18
+ not an API dump.
15
19
  sources:
16
20
  - 'northguild/gmt:README.md'
17
21
  - 'northguild/gmt:packages/gmt/src/zoned/get/index.ts'
@@ -30,10 +34,13 @@ sources:
30
34
  - 'northguild/gmt:packages/gmt/src/instant/convert/index.ts'
31
35
  - 'northguild/gmt:packages/gmt/src/calendar/calculate/index.ts'
32
36
  - 'northguild/gmt:packages/gmt/src/calendar/validate/index.ts'
37
+ - 'northguild/gmt:packages/gmt/src/transport/calculate/index.ts'
38
+ - 'northguild/gmt:packages/gmt/src/transport/convert/index.ts'
39
+ - 'northguild/gmt:packages/gmt/src/intermodal/calculate/index.ts'
33
40
  metadata:
34
41
  type: core
35
42
  library: '@northguild/gmt'
36
- library_version: '1.16.0'
43
+ library_version: '1.17.0'
37
44
  ---
38
45
 
39
46
  # GMT Timezone
@@ -53,6 +60,12 @@ converting between time zones, or doing arithmetic that must respect DST.
53
60
  - The user needs the start or end of a local hour, day, week, month or quarter.
54
61
  - The user is grouping or aggregating UTC timestamps by local day, hour, week or
55
62
  month — an observability rollup, a chargeable-days count.
63
+ - The user is adding a leg's transit time to a departure, showing an arrival in
64
+ the zone where it lands, or counting how long cargo, a vessel or a patient sat
65
+ somewhere in local calendar days.
66
+ - The user is working out when a container's free time ends, how many days of
67
+ demurrage or detention are chargeable and for which dates, or which events a
68
+ charge's clock runs between.
56
69
 
57
70
  ## Core rules
58
71
 
@@ -164,7 +177,57 @@ converting between time zones, or doing arithmetic that must respect DST.
164
177
  `formatZonedRange` and `formatZonedToParts` return `""`/`[]` for a
165
178
  `timeZone` option. To show an instant in another zone, use
166
179
  `formatUtc(convertZonedToUtc(value), locale, { timeZone })`.
167
- 15. **Read the README.** This skill is a routing pointer. For the full DST
180
+ 15. **Transport legs are exact time; dwell is counted in local days.**
181
+ `transitTime(departure, duration)` adds hours, minutes and seconds as
182
+ elapsed time (`P1D` is 24 exact hours) in the departure's own zone, so a leg
183
+ across a DST transition lands at the wall time the vehicle really arrives;
184
+ years, months and weeks return `""`, and a bracketed zone that contradicts
185
+ its offset is rejected rather than reinterpreted. `etaAtZone(instant, zone)`
186
+ renders a moment in the zone the caller names — no disambiguation arises,
187
+ the offset in the result tells the two passes of a fall-back hour apart, and
188
+ GMT never resolves a port, airport or station code to a zone.
189
+ `dwellTime(entry, exit, targetZone?)` returns `{ duration, enter, exit,
190
+ calendarDays }`; `calendarDays` is the number of distinct local dates the
191
+ half-open `[entry, exit)` touches, walked across the zone's real transitions
192
+ (a skipped date is not counted, a re-entered one only once), and is the
193
+ library's one "local days crossed" count.
194
+ Bare instants with no `targetZone` return `null`: an offset is not a place.
195
+ 16. **Free time is counted in the terminal's local days; the start day and the
196
+ basis are tariff terms, never defaults.**
197
+ `freeTimeExpiry(clockStart, freeDays, { basis, timeZone, firstDay, calendar? })`
198
+ returns `{ freeTimeStart, lastFreeDay, expiresAt }`: local dates in
199
+ `timeZone`, and the first instant of the day after the last free day.
200
+ `firstDay` (`"eventDay"` | `"nextDay"`) has no default because the two
201
+ differ by a day of charges; `basis: "working"` needs a `BusinessCalendar`
202
+ and returns `null` without one. `chargeableDays(clockStart, clockEnd,
203
+ freeDays, options)` also needs `chargeBasis` (no default): many tariffs
204
+ count both in calendar days; where a tariff grants free time in working
205
+ days the days after it are mostly charged as calendar days, and some
206
+ tariffs charge working days only. It counts the days on or after
207
+ `expiresAt` the half-open dwell touched, lists them as `chargedDates`, and
208
+ splits them into `tiers` bands; `freeDays: 0` is allowed there.
209
+ `demurrageClock(events, scope, { direction, startEvent? })` selects the
210
+ events per leg: import demurrage and storage run discharge (or
211
+ availability) to gate-out, detention gate-out to empty return; export
212
+ demurrage gate-in to loaded, detention empty release to gate-in; `combined`
213
+ runs both as one period. No standard fixes how these days are counted;
214
+ every term is the tariff's.
215
+ 17. **Billing deadlines are dates counted from an anchor, and every window is
216
+ the caller's.** `billingTimeline({ anchorOn, invoiceIssuedOn?,
217
+ requestReceivedOn? }, { issueDays, disputeDays, resolutionDays,
218
+ agreedResolutionOn? })` returns `{ invoiceDeadline, issuedByDeadline,
219
+ disputeDeadline, requestedByDeadline, resolutionDeadline }`. Day zero is
220
+ the anchor and each deadline is `date + days` on the ISO calendar; a date
221
+ is by the deadline when it is on or before it. No window has a default (a
222
+ missing one returns `null`); fields whose input does not exist yet are
223
+ `null`, so an anchor alone is a forecast. The anchor is whatever date the
224
+ caller counts from: the last charged date
225
+ (`chargedDates.at(-1)`), or for a re-bill the issuance date of the invoice
226
+ received. Reduce an instant to the billing party's local date first with
227
+ `convertUtcToPlainDate(instant, { timeZone })`. A request before its
228
+ invoice, or an agreed date before the request, returns `null`. GMT
229
+ computes dates, not liability.
230
+ 18. **Read the README.** This skill is a routing pointer. For the full DST
168
231
  disambiguation walkthrough, code examples, and locale ICU notes, read the
169
232
  installed package's `README.md` and the source JSDoc.
170
233
 
@@ -190,6 +253,10 @@ converting between time zones, or doing arithmetic that must respect DST.
190
253
  - **Local-time resolution**: `classifyLocal`, `resolveLocal`
191
254
  - **Zone-aware buckets**: `floorToZone`, `bucketRange`,
192
255
  `isValidZoneBucketUnit`
256
+ - **Transport legs and dwell**: `transitTime`, `etaAtZone`, `dwellTime`
257
+ - **Free time and demurrage**: `freeTimeExpiry`, `chargeableDays`,
258
+ `demurrageClock`
259
+ - **Billing deadlines**: `billingTimeline`
193
260
 
194
261
  ## References
195
262