@@ -6,6 +6,13 @@ All functions accept flexible date inputs and return timestamps (milliseconds si
66type DateInput = number | string | Date ;
77```
88
9+ ::: warning v2.0 Breaking Changes
10+ - ` parse() ` now uses ** local time** for date-only strings (was UTC)
11+ - Getter functions now return ** local time** components (was UTC)
12+
13+ See [ Release Notes] ( /RELEASE_NOTES_v2.0.0.md ) for migration guide.
14+ :::
15+
916## Parsing
1017
1118| Function | Description |
@@ -122,6 +129,32 @@ getComponents(date); // { year: 2025, month: 11, day: 30, ... }
122129
123130---
124131
132+ ## Setters
133+
134+ Immutable setters that return new timestamps:
135+
136+ | Function | Description |
137+ | ----------| -------------|
138+ | ` setYear(date, year) ` | Set year |
139+ | ` setMonth(date, month) ` | Set month (1-12) |
140+ | ` setDate(date, day) ` | Set day of month |
141+ | ` setHours(date, hours) ` | Set hours |
142+ | ` setMinutes(date, minutes) ` | Set minutes |
143+ | ` setSeconds(date, seconds) ` | Set seconds |
144+ | ` setMilliseconds(date, ms) ` | Set milliseconds |
145+
146+ ``` typescript
147+ setYear (date , 2026 ); // New timestamp with year 2026
148+ setMonth (date , 3 ); // New timestamp with March
149+ setDate (setMonth (date , 3 ), 15 ); // March 15th
150+ ```
151+
152+ ::: tip
153+ Setters handle edge cases automatically. Setting month to February when day is 31 will clamp to 28/29.
154+ :::
155+
156+ ---
157+
125158## Arithmetic
126159
127160| Function | Description |
@@ -194,6 +227,38 @@ isLeapYear(date); // false
194227
195228---
196229
230+ ## Timezone-Aware Predicates
231+
232+ Check dates in specific timezones. Essential for global apps where "today" depends on location.
233+
234+ | Function | Description |
235+ | ----------| -------------|
236+ | ` isTodayInTz(date, tz) ` | Today in timezone? |
237+ | ` isTomorrowInTz(date, tz) ` | Tomorrow in timezone? |
238+ | ` isYesterdayInTz(date, tz) ` | Yesterday in timezone? |
239+ | ` isSameDayInTz(date1, date2, tz) ` | Same day in timezone? |
240+ | ` isSameMonthInTz(date1, date2, tz) ` | Same month in timezone? |
241+ | ` isSameYearInTz(date1, date2, tz) ` | Same year in timezone? |
242+ | ` startOfDayInTz(date, tz) ` | Midnight in timezone |
243+ | ` endOfDayInTz(date, tz) ` | 23:59:59.999 in timezone |
244+
245+ ``` typescript
246+ // Check if timestamp is "today" in Tokyo
247+ isTodayInTz (date , ' Asia/Tokyo' );
248+
249+ // Get midnight in New York (returns UTC timestamp)
250+ startOfDayInTz (date , ' America/New_York' );
251+
252+ // Compare two dates in London timezone
253+ isSameDayInTz (date1 , date2 , ' Europe/London' );
254+ ```
255+
256+ ::: tip Use Case
257+ A global restaurant app needs to check if an order was placed "today" in the restaurant's local timezone, not the user's device timezone.
258+ :::
259+
260+ ---
261+
197262## Boundaries
198263
199264| Function | Description |
@@ -259,6 +324,7 @@ formatDuration(3600000); // "1h 0m 0s"
259324| ` getTimezone() ` | Device timezone ID |
260325| ` getTimezoneOffset() ` | Offset in minutes |
261326| ` getTimezoneOffsetForTimestamp(date) ` | Offset at date |
327+ | ` getOffsetInTimezone(date, tz) ` | Offset for timezone at date |
262328| ` toTimezone(date, tz) ` | Convert to timezone |
263329| ` toUTC(date) ` | Convert to UTC |
264330| ` getAvailableTimezones() ` | All timezone IDs |
0 commit comments