@procedures/ics 0.6.0 → 0.8.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # @procedures/ics
2
2
 
3
+ ## 0.8.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 6cbc15a: Two additions for the calendar dates and the feeds.
8
+
9
+ - New `shiftMonth(date, months)` gives the date `months` months after a date (`YYYY-MM-DD`). When the month of the result does not have the day, the result is its last day: one month after `2026-01-31` is `2026-02-28`. For the arithmetic of `Date.UTC`, add the days to the 1st with `shiftDay`.
10
+ - `fetchCalendar` has a new option `fetch`, the fourth argument. It replaces the global `fetch`, as the option `fetch` of `drivingRoute` in `@procedures/geo` does.
11
+ - The README lists `localTime`, `weekdayOf` and `weekdayName`, which came in 0.7.0.
12
+ - Updated dependencies [4b09a03]
13
+ - Updated dependencies [4b09a03]
14
+ - Updated dependencies [aa6e3aa]
15
+ - Updated dependencies [698e24d]
16
+ - Updated dependencies [4b09a03]
17
+ - Updated dependencies [600c497]
18
+ - Updated dependencies [7c2e7f7]
19
+ - Updated dependencies [90ea741]
20
+ - Updated dependencies [c4cfa34]
21
+ - Updated dependencies [d25805a]
22
+ - @procedures/client@0.8.0
23
+
24
+ ## 0.7.0
25
+
26
+ ### Minor Changes
27
+
28
+ - 01dce14: `localTime(instant, timeZone)` gives the time (`HH:MM`, 24 hours) that a clock in a zone shows at an instant. `weekdayOf(date)` gives the day of the week (0 for Sunday), and `weekdayName(date)` its name. jarvis had seven copies of these.
29
+
30
+ ### Patch Changes
31
+
32
+ - Updated dependencies [841d083]
33
+ - Updated dependencies [389b054]
34
+ - @procedures/client@0.7.0
35
+
3
36
  ## 0.6.0
4
37
 
5
38
  ### Minor Changes
package/README.md CHANGED
@@ -71,27 +71,34 @@ The reader changes a `TZID` time to UTC as RFC 5545 (3.3.5) tells. The function
71
71
 
72
72
  ## Calendar days
73
73
 
74
- The package also exports four functions for calendar days. They use `Intl` only, without a time zone database, as `@procedures/schedule` does.
74
+ The package also exports these functions for calendar days. They use `Intl` only, without a time zone database, as `@procedures/schedule` does.
75
75
 
76
76
  | Function | What it gives |
77
77
  | --- | --- |
78
78
  | `localDate(instant, timeZone)` | The date (`YYYY-MM-DD`) that a clock in the zone shows at the instant. The instant is a `Date`, the milliseconds since 1970 or a text. |
79
79
  | `zonedOffset(date, time, timeZone)` | The UTC offset (`+HH:MM` or `-HH:MM`) of a local time (`HH:MM` or `HH:MM:SS`) on a date, with the rules of RFC 5545. |
80
+ | `localTime(instant, timeZone)` | The time (`HH:MM`, from 00:00 to 23:59) that a clock in the zone shows at the instant. |
80
81
  | `shiftDay(date, days)` | The date `days` days after a date. A negative number gives an earlier date. |
82
+ | `shiftMonth(date, months)` | The date `months` months after a date. When the month does not have the day, the result is its last day. |
81
83
  | `daysBetween(from, to)` | The number of whole days from one date to another. It is negative when `to` is before `from`. |
84
+ | `weekdayOf(date)` | The day of the week of a date: 0 for Sunday to 6 for Saturday. |
85
+ | `weekdayName(date, options)` | The name of the day of the week of a date. The default is the long English name. |
82
86
 
83
87
  ```ts
84
- import { daysBetween, localDate, shiftDay, zonedOffset } from "@procedures/ics";
88
+ import { daysBetween, localDate, shiftDay, shiftMonth, weekdayName, zonedOffset } from "@procedures/ics";
85
89
 
86
90
  localDate("2026-10-17T03:00:00Z", "America/New_York"); // "2026-10-16"
87
91
  zonedOffset("2026-03-08", "02:30", "America/New_York"); // "-05:00": 02:30-05:00 is 03:30 daylight time
88
92
  shiftDay("2026-03-07", 2); // "2026-03-09"
93
+ shiftMonth("2026-01-31", 1); // "2026-02-28"
94
+ shiftDay(shiftMonth("2026-01-01", 1), 30); // "2026-03-03": the arithmetic of Date.UTC
95
+ weekdayName("2026-10-17"); // "Saturday"
89
96
  daysBetween("2026-10-31", "2026-11-02"); // 2
90
97
  ```
91
98
 
92
99
  - A date is a text `YYYY-MM-DD` of the years 0000 to 9999. `2026-02-30` is not a date.
93
100
  - `shiftDay` and `daysBetween` use the arithmetic of UTC. A change of daylight saving time does not move a date.
94
- - The number of days of `shiftDay` must be an integer.
101
+ - The number of days of `shiftDay` and the number of months of `shiftMonth` must be integers.
95
102
  - `localDate` gives the result of the `en-CA` format of `Intl`, with the year in four digits.
96
103
  - The time zone is an IANA name that `Intl` knows, for example `Europe/Berlin` or `UTC`.
97
104
  - A value that is not correct throws a `RangeError`: a date, a time, an instant or a time zone.
@@ -99,3 +106,5 @@ daysBetween("2026-10-31", "2026-11-02"); // 2
99
106
  ## Private feeds
100
107
 
101
108
  The address of a private calendar feed is a secret. `ics.fetch` does not put the address in an error message.
109
+
110
+ The function `fetchCalendar(url, timeoutMs, signal, { fetch })` gets the text of a feed. It refuses an HTTP error and a page that is not a calendar. The option `fetch` replaces the global `fetch`, for a test or a host with its own client.