@@ -10,11 +10,11 @@ addDays(dateObj, days[, timeZone])
1010
1111### Parameters
1212
13- | Parameter | Type | Required | Description |
14- | -----------| ------| ----------| -------------|
15- | ` dateObj ` | ` Date ` | Yes | The base Date object |
16- | ` days ` | ` number ` | Yes | Number of days to add (positive) or subtract (negative) |
17- | ` timeZone ` | ` TimeZone \| string ` | No | Timezone for the calculation |
13+ | Parameter | Type | Required | Description |
14+ | ------------ | ---------------------- | ----------| -------------------------------------------- -------------|
15+ | ` dateObj ` | ` Date ` | Yes | The base Date object |
16+ | ` days ` | ` number ` | Yes | Number of days to add (positive) or subtract (negative) |
17+ | ` timeZone ` | ` TimeZone \| string ` | No | Timezone for the calculation |
1818
1919### Returns
2020
@@ -42,34 +42,19 @@ console.log(past); // August 10, 2024
4242
4343``` typescript
4444import { addDays } from ' date-and-time' ;
45- import New_York from ' date-and-time/timezones/America/New_York' ;
4645
4746// Working with specific timezones
4847const nyDate = new Date (' 2024-03-10T05:00:00Z' ); // March 10, 2024 05:00 UTC (DST transition day)
4948
5049// Add 30 days in New York timezone
51- const futureNY = addDays (nyDate , 30 , New_York );
50+ const futureNY = addDays (nyDate , 30 , ' America/ New_York' );
5251console .log (futureNY ); // April 9, 2024 04:00 UTC (EDT, DST adjusted)
5352
5453// UTC calculation for comparison
5554const futureUTC = addDays (nyDate , 30 , ' UTC' );
5655console .log (futureUTC ); // April 9, 2024 05:00 UTC (same time, no DST adjustment)
5756```
5857
59- ### Using IANA Timezone Name Strings
60-
61- As of v4.3.0, you can use IANA timezone name strings directly instead of importing TimeZone objects:
62-
63- ``` typescript
64- import { addDays } from ' date-and-time' ;
65-
66- const nyDate = new Date (' 2024-03-10T05:00:00Z' ); // March 10, 2024 05:00 UTC
67-
68- // Using IANA timezone name string (New in v4.3.0)
69- const futureNY = addDays (nyDate , 30 , ' America/New_York' );
70- console .log (futureNY ); // April 9, 2024 04:00 UTC (EDT, DST adjusted)
71- ```
72-
7358## Use Cases
7459
7560### Work Day Calculations
0 commit comments