@northguild/gmt 1.14.2 → 1.15.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 (137) hide show
  1. package/README.md +43 -13
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.js +1 -0
  4. package/dist/plain/calculate/diffDateAsDuration.js +1 -1
  5. package/dist/plain/calculate/index.d.ts +2 -1
  6. package/dist/plain/calculate/index.js +2 -1
  7. package/dist/plain/calculate/{weekOfYear.d.ts → weekOfYearForDate.d.ts} +0 -14
  8. package/dist/plain/calculate/weekOfYearForDate.js +28 -0
  9. package/dist/plain/calculate/weekOfYearForDateTime.d.ts +14 -0
  10. package/dist/plain/calculate/{weekOfYear.js → weekOfYearForDateTime.js} +1 -27
  11. package/dist/plain/format/formatCalendar.d.ts +2 -2
  12. package/dist/plain/format/formatDate.d.ts +3 -2
  13. package/dist/plain/format/formatDate.js +1 -1
  14. package/dist/plain/format/formatDateRange.d.ts +3 -2
  15. package/dist/plain/format/formatDateRange.js +1 -1
  16. package/dist/plain/format/formatDateTime.d.ts +3 -2
  17. package/dist/plain/format/formatDateTime.js +1 -1
  18. package/dist/plain/format/formatDateTimeRange.d.ts +3 -2
  19. package/dist/plain/format/formatDateTimeRange.js +1 -1
  20. package/dist/plain/format/formatDateTimeToParts.d.ts +3 -2
  21. package/dist/plain/format/formatDateTimeToParts.js +1 -1
  22. package/dist/plain/format/formatDateToParts.d.ts +3 -2
  23. package/dist/plain/format/formatDateToParts.js +1 -1
  24. package/dist/plain/format/formatRelativeDate.d.ts +3 -14
  25. package/dist/plain/format/formatRelativeDateTime.d.ts +3 -14
  26. package/dist/plain/format/formatRelativeTime.d.ts +3 -14
  27. package/dist/plain/format/formatTime.d.ts +2 -1
  28. package/dist/plain/get/getNowUnit.d.ts +2 -3
  29. package/dist/plain/interval/splitIntervalByUnitDate.js +1 -1
  30. package/dist/regex/calendar-date.d.ts +19 -0
  31. package/dist/regex/calendar-date.js +19 -10
  32. package/dist/regex/calendar-zoned-date-time.d.ts +45 -0
  33. package/dist/regex/calendar-zoned-date-time.js +45 -40
  34. package/dist/regex/date-time.d.ts +18 -0
  35. package/dist/regex/date-time.js +18 -1
  36. package/dist/regex/date.d.ts +16 -0
  37. package/dist/regex/date.js +16 -1
  38. package/dist/regex/http-date.d.ts +15 -0
  39. package/dist/regex/http-date.js +15 -6
  40. package/dist/regex/leap-second.d.ts +12 -0
  41. package/dist/regex/leap-second.js +12 -1
  42. package/dist/regex/rfc-2822.d.ts +18 -0
  43. package/dist/regex/rfc-2822.js +18 -8
  44. package/dist/regex/rfc-3339.d.ts +19 -0
  45. package/dist/regex/rfc-3339.js +19 -6
  46. package/dist/regex/sql-date-time.d.ts +14 -0
  47. package/dist/regex/sql-date-time.js +14 -6
  48. package/dist/regex/time-zone-like.d.ts +21 -0
  49. package/dist/regex/time-zone-like.js +21 -0
  50. package/dist/regex/time.d.ts +59 -0
  51. package/dist/regex/time.js +59 -3
  52. package/dist/regex/unix.d.ts +21 -0
  53. package/dist/regex/unix.js +21 -0
  54. package/dist/regex/utc-date-time.d.ts +20 -0
  55. package/dist/regex/utc-date-time.js +20 -1
  56. package/dist/types/calendar-options.d.ts +11 -0
  57. package/dist/types/calendar-options.js +0 -0
  58. package/dist/types/datetime-format-options.d.ts +6 -0
  59. package/dist/types/datetime-format-options.js +0 -0
  60. package/dist/types/duration-unit.d.ts +5 -0
  61. package/dist/types/duration-unit.js +0 -0
  62. package/dist/types/index.d.ts +11 -0
  63. package/dist/types/index.js +11 -0
  64. package/dist/types/now-unit.d.ts +5 -0
  65. package/dist/types/now-unit.js +0 -0
  66. package/dist/types/relative-date-time-unit.d.ts +6 -0
  67. package/dist/types/relative-date-time-unit.js +0 -0
  68. package/dist/types/relative-date-unit.d.ts +5 -0
  69. package/dist/types/relative-date-unit.js +0 -0
  70. package/dist/types/relative-time-options.d.ts +18 -0
  71. package/dist/types/relative-time-options.js +0 -0
  72. package/dist/types/relative-time-unit.d.ts +5 -0
  73. package/dist/types/relative-time-unit.js +0 -0
  74. package/dist/types/relative-unit.d.ts +6 -0
  75. package/dist/types/relative-unit.js +0 -0
  76. package/dist/types/unix-now-unit.d.ts +5 -0
  77. package/dist/types/unix-now-unit.js +0 -0
  78. package/dist/types/utc-now-unit.d.ts +5 -0
  79. package/dist/types/utc-now-unit.js +0 -0
  80. package/dist/unix/calculate/startOrEndOfUnix.d.ts +18 -0
  81. package/dist/unix/calculate/startOrEndOfUnix.js +18 -0
  82. package/dist/unix/format/formatCalendarUnix.d.ts +27 -1
  83. package/dist/unix/format/formatRelativeUnix.d.ts +1 -8
  84. package/dist/unix/format/formatUnix.d.ts +19 -0
  85. package/dist/unix/format/formatUnix.js +19 -0
  86. package/dist/unix/get/getUnixNowUnit.d.ts +2 -3
  87. package/dist/unix/parse/parseUnitFromUnix.d.ts +24 -0
  88. package/dist/unix/validate/isValidUnixUnit.d.ts +15 -0
  89. package/dist/utc/calculate/startOrEndOfUtc.d.ts +17 -0
  90. package/dist/utc/calculate/startOrEndOfUtc.js +17 -0
  91. package/dist/utc/format/formatCalendarUtc.d.ts +2 -2
  92. package/dist/utc/format/formatRelativeUtc.d.ts +2 -12
  93. package/dist/utc/format/formatUtc.d.ts +33 -0
  94. package/dist/utc/format/formatUtc.js +17 -0
  95. package/dist/utc/get/getUtcNowUnit.d.ts +2 -3
  96. package/dist/utc/parse/parseUnitFromUtc.d.ts +23 -0
  97. package/dist/zoned/format/formatRelativeZoned.d.ts +1 -8
  98. package/dist/zoned/format/formatTimeZoneName.d.ts +15 -0
  99. package/dist/zoned/format/formatZonedDateTime.d.ts +2 -1
  100. package/dist/zoned/format/formatZonedRange.d.ts +2 -1
  101. package/dist/zoned/format/formatZonedToParts.d.ts +2 -1
  102. package/dist/zoned/get/getDstTransitions.d.ts +18 -2
  103. package/dist/zoned/get/getZonedNowUnit.d.ts +24 -0
  104. package/dist/zoned/interval/intervalDifferenceZoned.d.ts +3 -3
  105. package/dist/zoned/interval/intervalDifferenceZoned.js +3 -3
  106. package/dist/zoned/interval/intervalXorZoned.d.ts +6 -4
  107. package/dist/zoned/interval/intervalXorZoned.js +6 -4
  108. package/dist/zoned/parse/getZonedOffsetAs.d.ts +11 -0
  109. package/dist/zoned/parse/parseUnitFromZoned.d.ts +24 -0
  110. package/package.json +25 -7
  111. package/skills/gmt-arithmetic/SKILL.md +83 -0
  112. package/skills/gmt-basics/SKILL.md +80 -0
  113. package/skills/gmt-integration/SKILL.md +73 -0
  114. package/skills/gmt-timezone/SKILL.md +80 -0
  115. package/skills/_artifacts/domain_map.yaml +0 -547
  116. package/skills/_artifacts/skill_spec.md +0 -67
  117. package/skills/_artifacts/skill_tree.yaml +0 -278
  118. package/skills/api-expansion-workflow/SKILL.md +0 -52
  119. package/skills/app-integration/SKILL.md +0 -38
  120. package/skills/calculate-dates/SKILL.md +0 -432
  121. package/skills/compare-dates/SKILL.md +0 -412
  122. package/skills/convert-types/SKILL.md +0 -305
  123. package/skills/durations/SKILL.md +0 -418
  124. package/skills/format-date-time/SKILL.md +0 -486
  125. package/skills/format-date-time/references/format-api.md +0 -34
  126. package/skills/format-relative-time/SKILL.md +0 -223
  127. package/skills/get-current/SKILL.md +0 -229
  128. package/skills/interval-ops/SKILL.md +0 -432
  129. package/skills/issue-creation/SKILL.md +0 -118
  130. package/skills/lint-package-suggestion/SKILL.md +0 -37
  131. package/skills/new-method-implementation/SKILL.md +0 -71
  132. package/skills/parse-date-time/SKILL.md +0 -349
  133. package/skills/pr-contribution/SKILL.md +0 -180
  134. package/skills/unit-test-generation/SKILL.md +0 -56
  135. package/skills/validate-dates/SKILL.md +0 -438
  136. package/skills/zoned-date-ops/SKILL.md +0 -422
  137. package/skills/zoned-date-ops/references/timezones.md +0 -13
@@ -0,0 +1,80 @@
1
+ ---
2
+ name: gmt-basics
3
+ description: >
4
+ Core date/time basics — get current values, parse components, format for
5
+ display, format relative time, compare dates, and validate
6
+ strings/timezones/intervals. Reads the installed package README.md and source
7
+ JSDoc for API details; this skill is a routing pointer, not an API dump.
8
+ sources:
9
+ - 'northguild/gmt:README.md'
10
+ - 'northguild/gmt:packages/gmt/src/plain/get/index.ts'
11
+ - 'northguild/gmt:packages/gmt/src/plain/parse/index.ts'
12
+ - 'northguild/gmt:packages/gmt/src/plain/format/index.ts'
13
+ - 'northguild/gmt:packages/gmt/src/plain/locale/index.ts'
14
+ - 'northguild/gmt:packages/gmt/src/plain/compare/index.ts'
15
+ - 'northguild/gmt:packages/gmt/src/plain/validate/index.ts'
16
+ - 'northguild/gmt:packages/gmt/src/zoned/get/index.ts'
17
+ - 'northguild/gmt:packages/gmt/src/zoned/format/index.ts'
18
+ - 'northguild/gmt:packages/gmt/src/zoned/validate/index.ts'
19
+ - 'northguild/gmt:packages/gmt/src/unix/get/index.ts'
20
+ - 'northguild/gmt:packages/gmt/src/utc/get/index.ts'
21
+ metadata:
22
+ type: core
23
+ library: '@northguild/gmt'
24
+ library_version: '1.15.0'
25
+ ---
26
+
27
+ # GMT Basics
28
+
29
+ Use this skill when the task touches core date/time read operations: getting the
30
+ current time, parsing components out of a date string, formatting for display,
31
+ producing human-friendly relative strings, comparing two values, or validating
32
+ input before you act on it.
33
+
34
+ ## When to load
35
+
36
+ - The user needs "now" as an ISO string, or a formatted/localized display value.
37
+ - The user wants to extract a year/month/day/hour from a date string.
38
+ - The user needs "yesterday" or "in 2 hours" style output.
39
+ - The user is comparing or sorting two date strings.
40
+ - The user wants to guard a call with a validity check first.
41
+
42
+ ## Core rules
43
+
44
+ 1. **ISO 8601 strings in.** Public APIs consume ISO strings, IANA timezone ids,
45
+ or numeric Unix epochs — never `new Date()`.
46
+ 2. **Sentinel returns, never throws.** `""` for strings, `null` for numbers,
47
+ `false` for booleans, `[]` for arrays. Always check before using.
48
+ 3. **Read the README.** This skill is a routing pointer. For full API
49
+ signatures, locale matrices, and code examples, read the installed package's
50
+ `README.md` and the source JSDoc of the function you intend to call.
51
+
52
+ ## Key functions
53
+
54
+ - **Current values**: `getNow`, `getToday`, `getUtcNow`, `getUnixNow`,
55
+ `getSystemTimeZone`, `getTimeZones`
56
+ - **Parsing**: `parseYearFromDate`, `parseMonthFromDate`,
57
+ `parseDateTimeWithPattern`, `parseRfc3339`, `parseHttp`, `parseSql`
58
+ - **Formatting**: `formatDate`, `formatTime`, `formatDateTime`,
59
+ `formatRelativeDate`, `formatCalendar`, `formatRfc3339`
60
+ - **Locale names**: `getLocaleMonthNames`, `getLocaleWeekdayNames`,
61
+ `getLocaleMeridiems`, `getLocaleEraNames`
62
+ - **Comparison**: `isAfterDate`, `isBeforeDate`, `areDatesEqual`,
63
+ `areDatesEqualBy`, `isWeekend`, `isBusinessDay`, `nextWeekday`
64
+ - **Validation**: `isValidDate`, `isValidTime`, `isValidTimeZone`,
65
+ `isValidZonedDateTime`, `isValidDateInterval`
66
+
67
+ ## Common pitfalls
68
+
69
+ - `formatRelativeDate` requires a `reference` option — without it, you get `""`.
70
+ - `parseDateWithPattern` returns `""` on shape-valid-but-unreal dates (regex
71
+ only proves shape; Temporal validates the real value).
72
+ - Week numbers are ambiguous across year boundaries — pair
73
+ `parseWeekFromDate` with `getWeekYear`.
74
+ - `isWeekend` is locale-aware via `Intl.Locale.weekInfo`; `isBusinessDay` is
75
+ fixed ISO Mon–Fri with no locale and no holidays.
76
+
77
+ ## References
78
+
79
+ - [README — API Surface and Quick Start](README.md)
80
+ - [Full API reference](/reference/plain)
@@ -0,0 +1,73 @@
1
+ ---
2
+ name: gmt-integration
3
+ description: >
4
+ Application integration patterns — stable cache keys, router/query params,
5
+ table-sort keys, and lint package selection (ESLint, Biome, Oxlint). Reads the
6
+ installed package README.md and lint-package READMEs for API details; this
7
+ skill is a routing pointer, not an API dump.
8
+ sources:
9
+ - 'northguild/gmt:README.md'
10
+ - 'northguild/gmt:packages/gmt/src/zoned/validate/index.ts'
11
+ metadata:
12
+ type: composition
13
+ library: '@northguild/gmt'
14
+ library_version: '1.15.0'
15
+ ---
16
+
17
+ # GMT Integration
18
+
19
+ Use this skill when integrating GMT into an application framework or choosing
20
+ which lint package to install for Date-ban enforcement.
21
+
22
+ ## When to load
23
+
24
+ - The user asks about cache keys, router params, or table-sort keys for dates.
25
+ - The user wants to validate a timezone id before using it as a cache key.
26
+ - The user is picking an ESLint, Biome, or Oxlint plugin to ban `Date` APIs.
27
+ - The user has a lint package but not the gmt runtime (or vice versa).
28
+
29
+ ## Core rules
30
+
31
+ 1. **Canonical, stable representations at boundaries.** Use ISO 8601 strings or
32
+ normalized epoch numbers for cache keys — never `Date` objects or fuzzy
33
+ strings. Different environments must produce the same key.
34
+ 2. **Validate before you key.** Always run `isValidTimeZone` on a timezone parameter
35
+ before using it as a cache key or router param — `"Invalid/Zone"` is a sentinel
36
+ failure, not a real zone.
37
+ 3. **Pick one canonical Unix unit.** If you mix epoch seconds and milliseconds,
38
+ convert explicitly with `convertUtcToUnix` / `convertUtcToUnixMs` rather than
39
+ dividing/multiplying by hand.
40
+ 4. **Lint packages are toolchain-specific, not mutually exclusive.** Recommend
41
+ only the one matching the project's existing linter; do not force all three.
42
+ 5. **Read the READMEs.** This skill is a routing pointer. For full integration
43
+ guidance, read the installed package's `README.md` and the matching
44
+ `@northguild/gmt-eslint` / `gmt-oxlint` / `gmt-biome` README.
45
+
46
+ ## Lint package selection
47
+
48
+ | Current lint stack | Recommend |
49
+ | --- | --- |
50
+ | ESLint | `@northguild/gmt-eslint` |
51
+ | Biome | `@northguild/gmt-biome` |
52
+ | Oxlint | `@northguild/gmt-oxlint` |
53
+ | No linter yet | Add one of the above; install `@northguild/gmt` first |
54
+
55
+ These can be used individually or together. If the project has a lint package
56
+ but no `@northguild/gmt`, suggest adding gmt to support safe Date-to-Temporal
57
+ refactors. Lint findings should point toward existing gmt methods first; only
58
+ suggest a new Temporal custom method (and an issue) when no gmt helper covers
59
+ the pattern.
60
+
61
+ ## Integration guidance
62
+
63
+ - **Query/cache keys**: `['events', { start: '2024-02-29', end: '2024-03-01' }]`
64
+ — ISO strings, validated.
65
+ - **Router params**: validate with `isValidDate` / `isValidTimeZone` before use.
66
+ - **Table sorting**: use ISO strings as sort keys for consistent ordering.
67
+ - **State management**: canonicalized strings/numbers at boundaries only.
68
+
69
+ ## References
70
+
71
+ - [README — Install and Design Philosophy](README.md)
72
+ - [Lint Package Selection guide](/guides/integration/linting/)
73
+ - [Core Rules](/core-rules/)
@@ -0,0 +1,80 @@
1
+ ---
2
+ name: gmt-timezone
3
+ description: >
4
+ Timezone-aware operations — get zoned now, format zoned datetimes/ranges,
5
+ convert between plain↔zoned↔UTC↔Unix, and DST disambiguation control on
6
+ construction and arithmetic. Reads the installed package README.md and source
7
+ JSDoc for API details; this skill is a routing pointer, not an API dump.
8
+ sources:
9
+ - 'northguild/gmt:README.md'
10
+ - 'northguild/gmt:packages/gmt/src/zoned/get/index.ts'
11
+ - 'northguild/gmt:packages/gmt/src/zoned/format/index.ts'
12
+ - 'northguild/gmt:packages/gmt/src/zoned/compare/index.ts'
13
+ - 'northguild/gmt:packages/gmt/src/zoned/convert/index.ts'
14
+ - 'northguild/gmt:packages/gmt/src/zoned/validate/index.ts'
15
+ - 'northguild/gmt:packages/gmt/src/zoned/calculate/addZoned.ts'
16
+ - 'northguild/gmt:packages/gmt/src/zoned/calculate/startOfZoned.ts'
17
+ - 'northguild/gmt:packages/gmt/src/zoned/calculate/clampZoned.ts'
18
+ - 'northguild/gmt:packages/gmt/src/unix/get/index.ts'
19
+ - 'northguild/gmt:packages/gmt/src/utc/get/index.ts'
20
+ - 'northguild/gmt:packages/gmt/src/utc/convert/index.ts'
21
+ metadata:
22
+ type: core
23
+ library: '@northguild/gmt'
24
+ library_version: '1.15.0'
25
+ ---
26
+
27
+ # GMT Timezone
28
+
29
+ Use this skill when the task requires IANA time zone awareness — formatting,
30
+ converting between time zones, or doing arithmetic that must respect DST.
31
+
32
+ ## When to load
33
+
34
+ - The user needs the current time in a specific timezone (`"America/New_York"`).
35
+ - The user wants to format a datetime with its zone attached.
36
+ - The user needs to convert a plain datetime to a zoned instant, or between
37
+ timezones, or between UTC and Unix epochs.
38
+ - The user is adding/subtracting durations across a DST transition.
39
+
40
+ ## Core rules
41
+
42
+ 1. **Use IANA timezone ids, not raw offsets.** `"2024-03-15T14:30:45[America/New_York]"`
43
+ is correct; bare `"-05:00"` loses the zone and can't observe DST rules.
44
+ 2. **DST disambiguation.** `convertPlainDateTimeToZoned`, `addZoned`, `startOfZoned`,
45
+ and `setZoned` accept `disambiguation` (`"compatible"` | `"earlier"` |
46
+ `"later"` | `"reject"`) for gap/overlap resolution. It only affects fall-back
47
+ overlaps, **not** spring-forward gaps — use `convertPlainDateTimeToZoned`
48
+ with `"reject"` for gap-safety.
49
+ 3. **The `offset` parameter.** Defaults to `"ignore"` so `disambiguation` takes
50
+ effect. Passing `offset: "prefer"` keeps the source offset and silently
51
+ disables `disambiguation` — leave it at default unless you need Temporal's
52
+ raw `.with()` semantics.
53
+ 4. **Calendar annotations.** GMT's zoned grammar puts `[u-ca=...]` **before**
54
+ `[timeZone]` — the reverse of RFC 9557. Only `addZoned`, `subtractZoned`,
55
+ `diffZoned`, and `convertZonedToCalendar` accept it; everything else rejects
56
+ it and returns `""`. Always produce these with `convertZonedToCalendar`.
57
+ 5. **Read the README.** This skill is a routing pointer. For the full DST
58
+ disambiguation walkthrough, code examples, and locale ICU notes, read the
59
+ installed package's `README.md` and the source JSDoc.
60
+
61
+ ## Key functions
62
+
63
+ - **Current**: `getZonedNow`, `getZonedToday`
64
+ - **Formatting**: `formatZonedDateTime`, `formatZonedRange`,
65
+ `formatRelativeZoned`, `formatTimeZoneName`
66
+ - **Validation**: `isValidTimeZone`, `isValidZonedDateTime`,
67
+ `hasDaylightSaving`, `getDstTransitions`, `isInDaylightSaving`
68
+ - **Conversion**: `convertPlainDateTimeToZoned`, `convertZonedToPlainDateTime`,
69
+ `convertUtcToZoned`, `convertZonedToUtc`, `convertZonedToCalendar`,
70
+ `convertUtcToUnix`, `convertUnixToUtc`
71
+ - **Arithmetic (with disambiguation)**: `addZoned`, `subtractZoned`, `clampZoned`,
72
+ `closestZonedTo`, `startOfZoned`, `endOfZoned`, `startOfQuarterForZoned`,
73
+ `setZoned`, `cycleZoned`, `mapZonedHoursInDay`, `getHoursInZonedDay`
74
+ - **Offset/DST reads**: `getZonedOffset`, `getZonedOffsetAs`,
75
+ `getTimeZoneOffset`, `parseTimezoneFromZoned`
76
+
77
+ ## References
78
+
79
+ - [README — Timezone and Calendar examples](README.md)
80
+ - [DST Disambiguation guide](https://gmt-dox.northguild.workers.dev/docs/dst-disambiguation/)