@ultimat3/time 31.6.1 → 31.7.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/package.json +3 -3
  2. package/src/schedule.ts +7 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/time",
3
- "version": "31.6.1",
3
+ "version": "31.7.0",
4
4
  "description": "UTC instants, DST-correct zone math, cron, durations and Intl formatting with an explicit timezone",
5
5
  "keywords": [
6
6
  "ultimate",
@@ -46,7 +46,7 @@
46
46
  "test": "bun test"
47
47
  },
48
48
  "dependencies": {
49
- "@ultimat3/core": "31.6.1",
50
- "@ultimat3/schema": "31.6.1"
49
+ "@ultimat3/core": "31.7.0",
50
+ "@ultimat3/schema": "31.7.0"
51
51
  }
52
52
  }
package/src/schedule.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  * are built from. Local means the *recipient's* local, and it survives DST.
4
4
  */
5
5
 
6
+ import { finiteCount } from '@ultimat3/core';
6
7
  import { scheduleInvalid, timezoneInvalid } from './errors';
7
8
  import type { Instant } from './instant';
8
9
  import { fromZoned, toZoned } from './zoned';
@@ -62,11 +63,15 @@ export function nextLocalSlot(slot: LocalSlot, after: Instant): Instant {
62
63
  throw timezoneInvalid(slot.zone);
63
64
  }
64
65
 
65
- /** The next `count` daily slots — a preview for the schedule screen. */
66
+ /**
67
+ * The next `count` daily slots — a preview for the schedule screen. `count` bounds the loop, so it
68
+ * is screened: `NaN` and `-1` answered `[]`, `2.5` ran three times, `Infinity` never stopped.
69
+ */
66
70
  export function nextLocalSlots(slot: LocalSlot, after: Instant, count: number): Instant[] {
71
+ const total = finiteCount('nextLocalSlots', 'count', count, 0);
67
72
  const slots: Instant[] = [];
68
73
  let cursor = after;
69
- for (let index = 0; index < count; index += 1) {
74
+ for (let index = 0; index < total; index += 1) {
70
75
  cursor = nextLocalSlot(slot, cursor);
71
76
  slots.push(cursor);
72
77
  }