tiny-ja-date 0.9.0 → 1.0.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 (2) hide show
  1. package/README.md +53 -20
  2. package/package.json +2 -1
package/README.md CHANGED
@@ -17,6 +17,11 @@ Tiny TypeScript date utilities for Japanese UI.
17
17
  npm install tiny-ja-date
18
18
  ```
19
19
 
20
+ The package provides an ES module and TypeScript declarations.
21
+ Version 1.0.0 was verified on Windows x64 with Node.js 26.13.1, npm 11.20.0,
22
+ and TypeScript 5.9.3. Time zone calculations use the runtime's
23
+ `Intl.DateTimeFormat` and its time zone data.
24
+
20
25
  ## Usage
21
26
 
22
27
  ```ts
@@ -28,6 +33,7 @@ import {
28
33
  formatRelativeJaDate,
29
34
  isBusinessDay,
30
35
  isWeekendJP,
36
+ listBusinessDays,
31
37
  nextBusinessDay,
32
38
  } from "tiny-ja-date"
33
39
 
@@ -52,6 +58,9 @@ addBusinessDays("2026-05-15", 2)
52
58
  countBusinessDays("2026-05-15", "2026-05-19")
53
59
  // 2
54
60
 
61
+ listBusinessDays("2026-05-15", "2026-05-19")
62
+ // Dates for 2026-05-15, 2026-05-18, and 2026-05-19
63
+
55
64
  const calendar = createBusinessCalendar({ timeZone: "Asia/Tokyo", weekendDays: [0] })
56
65
  calendar.isBusinessDay("2026-11-21")
57
66
  // true
@@ -122,6 +131,7 @@ isBusinessDay("2026-11-24", options)
122
131
  Returns a `Date` for the start of the next business day in the selected time
123
132
  zone. If midnight is skipped, the result is the first valid time on that date.
124
133
  If a time zone skipped an entire date, the search continues to the following date.
134
+ Calling `toISOString()` on the result displays the instant in UTC.
125
135
 
126
136
  The search starts the day after the input and skips weekly closures and dates
127
137
  in `options.holidays`. Each holiday accepts the same `DateInput` type as the
@@ -201,6 +211,9 @@ listBusinessDays("2026-11-20", "2026-11-24", options)
201
211
 
202
212
  listBusinessDays("2026-11-24", "2026-11-20", options)
203
213
  // Starts of November 24, 21, and 20 in Tokyo
214
+
215
+ countBusinessDays("2026-11-20", "2026-11-24", options)
216
+ // 2, starting the count after November 20
204
217
  ```
205
218
 
206
219
  ### `createBusinessCalendar(options?: BusinessDayOptions): BusinessCalendar`
@@ -263,9 +276,9 @@ countBusinessDays("2026-11-20", "2026-11-24", options) // 2 (Saturday and Tuesda
263
276
  ## Time zones
264
277
 
265
278
  All public functions accept an optional `timeZone` such as `"Asia/Tokyo"`.
266
- When omitted, they keep the runtime-local behavior of 0.2. The runtime's
267
- `Intl.DateTimeFormat` supplies the time zone rules. Unrecognized IANA names
268
- throw a `RangeError`.
279
+ The selected zone applies to input dates, base dates, range endpoints, and
280
+ holidays. Omitting it uses the runtime's local time zone. Unrecognized IANA
281
+ names throw a `RangeError`.
269
282
 
270
283
  ```ts
271
284
  const tokyo = { timeZone: "Asia/Tokyo" }
@@ -282,15 +295,14 @@ nextBusinessDay("2026-11-20", { ...tokyo, holidays: ["2026-11-23"] }).toISOStrin
282
295
 
283
296
  ## Date inputs
284
297
 
285
- - `YYYY-MM-DD` strings represent calendar dates as written in the selected time
286
- zone. The runtime-local zone is used when no zone is specified.
287
- Invalid dates such as `2026-02-30` throw a `TypeError`.
288
- - `Date` objects and Unix timestamps in milliseconds represent instants. The
289
- functions use the instant's date in the selected time zone.
290
- - For strings with a time, use ISO 8601 with an explicit offset such as
291
- `2026-05-12T09:00:00+09:00` to identify an instant. With an explicit
292
- `timeZone`, date-time strings without an offset and other string formats
293
- throw a `TypeError`. Without `timeZone`, they follow JavaScript's `Date` parsing.
298
+ | Input | Interpretation |
299
+ | --- | --- |
300
+ | `"2026-11-24"` | The calendar date as written in the selected zone. |
301
+ | A `Date`, a Unix timestamp in milliseconds, or `"2026-11-23T15:30:00Z"` | An instant. The functions use its calendar date in the selected zone. |
302
+ | `"2026-11-24T00:30:00"` or other string formats | Follows JavaScript's `Date` parsing when `timeZone` is omitted. With an explicit `timeZone`, these inputs throw a `TypeError`. |
303
+
304
+ An invalid calendar date such as `2026-02-30` throws a `TypeError`.
305
+ When time matters, use ISO 8601 with `Z` or a numeric offset such as `+09:00`.
294
306
 
295
307
  ### Upgrading from 0.1
296
308
 
@@ -300,14 +312,8 @@ as `2026-05-12T00:00:00Z` to retain the 0.1 interpretation.
300
312
 
301
313
  ## Design policy
302
314
 
303
- `tiny-ja-date` is intentionally small.
304
-
305
- It does not:
306
-
307
- - include Japanese holiday data
308
- - format wareki
309
- - generate calendars
310
- - replace date-fns or dayjs
315
+ `tiny-ja-date` focuses on Japanese date labels and business-day calculations.
316
+ Supply organization-specific holidays through `holidays`.
311
317
 
312
318
  ---
313
319
 
@@ -321,6 +327,33 @@ Run `npm run build:demo` after changing the library source to refresh
321
327
  - GitHub → `https://github.com/fusaihanabi/tiny-ja-date`
322
328
  - Official → `https://dl.fusai-hanabi.com`
323
329
 
330
+ ## Release checks
331
+
332
+ With the development dependencies installed, run the tests. In PowerShell,
333
+ the following checks both runtime-local behavior and explicit time zones
334
+ using each of the three runtime defaults.
335
+
336
+ ```powershell
337
+ foreach ($zone in @('Asia/Tokyo', 'America/Los_Angeles', 'Pacific/Apia')) {
338
+ $env:TZ = $zone
339
+ npm test -- --run
340
+ if ($LASTEXITCODE -ne 0) { throw "Tests failed in $zone" }
341
+ }
342
+ ```
343
+
344
+ Then rebuild the demo and verify the package.
345
+
346
+ ```bash
347
+ npm run build:demo
348
+ npm run check:package
349
+ ```
350
+
351
+ `check:package` builds the library, creates a tarball with `npm pack`, and
352
+ installs it offline in a temporary consumer project. It type-checks the
353
+ consumer using Node-style ESM resolution, then runs the emitted JavaScript
354
+ against the installed package. The check covers imports, exported types,
355
+ and representative date and business-day examples.
356
+
324
357
  ---
325
358
 
326
359
  ## License
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiny-ja-date",
3
- "version": "0.9.0",
3
+ "version": "1.0.0",
4
4
  "description": "Tiny TypeScript date utilities for Japanese UI.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -17,6 +17,7 @@
17
17
  "scripts": {
18
18
  "build": "tsc",
19
19
  "build:demo": "tsc --declaration false --outDir docs",
20
+ "check:package": "npm run build && node scripts/check-package.mjs",
20
21
  "test": "vitest",
21
22
  "prepublishOnly": "npm test -- --run && npm run build"
22
23
  },