Skip to content

Commit 9d8c8d8

Browse files
authored
Merge pull request #85 from epilot-dev/chore/update-deadlines-docs
Update documentation for switching deadlines lib
2 parents 783c581 + 65ac327 commit 9d8c8d8

25 files changed

+195
-132
lines changed

docs/deadlines/deadlines-library/index/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020

2121
## Interfaces
2222

23+
- [CalendarProviderOptions](interfaces/CalendarProviderOptions.md)
2324
- [CalendarVersion](interfaces/CalendarVersion.md)
2425
- [CustomHolidayConfig](interfaces/CustomHolidayConfig.md)
2526
- [DayInfo](interfaces/DayInfo.md)
27+
- [DeadlineCalculatorOptions](interfaces/DeadlineCalculatorOptions.md)
2628
- [DeadlineRule](interfaces/DeadlineRule.md)
2729
- [Holiday](interfaces/Holiday.md)
2830
- [SwitchingCase](interfaces/SwitchingCase.md)

docs/deadlines/deadlines-library/index/classes/CalendarProvider.md

Lines changed: 20 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# Class: CalendarProvider
88

9-
Defined in: [calendar-provider.ts:41](https://github.com/epilot-dev/switching-deadlines/blob/6764c18ea2525d949c8b9824eea28bc98b53665e/src/calendar-provider.ts#L41)
9+
Defined in: [calendar-provider.ts:68](https://github.com/epilot-dev/switching-deadlines/blob/3e728b5f762c5b978f43c05453d07a8b73878933/src/calendar-provider.ts#L68)
1010

1111
Calendar provider that manages holidays, working days, and date calculations.
1212

@@ -39,39 +39,17 @@ const nextWorking = calendar.getNextWorkingDay('2024-12-25');
3939

4040
> **new CalendarProvider**(`options?`): `CalendarProvider`
4141
42-
Defined in: [calendar-provider.ts:81](https://github.com/epilot-dev/switching-deadlines/blob/6764c18ea2525d949c8b9824eea28bc98b53665e/src/calendar-provider.ts#L81)
42+
Defined in: [calendar-provider.ts:104](https://github.com/epilot-dev/switching-deadlines/blob/3e728b5f762c5b978f43c05453d07a8b73878933/src/calendar-provider.ts#L104)
4343

4444
Creates a new CalendarProvider instance.
4545

4646
#### Parameters
4747

4848
##### options?
4949

50-
Configuration options for the calendar
50+
[`CalendarProviderOptions`](../interfaces/CalendarProviderOptions.md)
5151

52-
###### customCalendar?
53-
54-
\{ `holidays?`: [`CustomHolidayConfig`](../interfaces/CustomHolidayConfig.md)[]; `version?`: [`CalendarVersion`](../interfaces/CalendarVersion.md); \}
55-
56-
Custom calendar configuration
57-
58-
###### customCalendar.holidays?
59-
60-
[`CustomHolidayConfig`](../interfaces/CustomHolidayConfig.md)[]
61-
62-
Array of custom holidays to include
63-
64-
###### customCalendar.version?
65-
66-
[`CalendarVersion`](../interfaces/CalendarVersion.md)
67-
68-
Version information for custom calendar
69-
70-
###### useSpecialHolidays?
71-
72-
`boolean`
73-
74-
Whether to include special holidays from the library (default: true)
52+
Optional configuration options for the calendar.
7553

7654
#### Returns
7755

@@ -85,14 +63,14 @@ const provider = new CalendarProvider({
8563
holidays: [
8664
{
8765
date: '2024-03-17',
88-
name: 'St. Patrick\'s Day',
66+
name: "St. Patrick's Day",
8967
type: HolidayType.SPECIAL_HOLIDAY,
90-
description: 'Irish cultural celebration'
91-
}
68+
description: 'Irish cultural celebration',
69+
},
9270
],
93-
version: { version: '1.0.0', year: 2024, lastUpdated: '2024-01-01T00:00:00Z' }
71+
version: { version: '1.0.0', year: 2024, lastUpdated: '2024-01-01T00:00:00Z' },
9472
},
95-
useSpecialHolidays: true
73+
useSpecialHolidays: true,
9674
});
9775
```
9876

@@ -102,7 +80,7 @@ const provider = new CalendarProvider({
10280

10381
> **addWorkingDays**(`startDate`, `workingDays`): `Date`
10482
105-
Defined in: [calendar-provider.ts:278](https://github.com/epilot-dev/switching-deadlines/blob/6764c18ea2525d949c8b9824eea28bc98b53665e/src/calendar-provider.ts#L278)
83+
Defined in: [calendar-provider.ts:295](https://github.com/epilot-dev/switching-deadlines/blob/3e728b5f762c5b978f43c05453d07a8b73878933/src/calendar-provider.ts#L295)
10684

10785
Adds a specified number of working days to a date, skipping weekends and holidays.
10886

@@ -143,7 +121,7 @@ const beforeHoliday = provider.addWorkingDays('2024-12-20', 3); // Skips Christm
143121

144122
> **countWorkingDays**(`startDate`, `endDate`): `number`
145123
146-
Defined in: [calendar-provider.ts:387](https://github.com/epilot-dev/switching-deadlines/blob/6764c18ea2525d949c8b9824eea28bc98b53665e/src/calendar-provider.ts#L387)
124+
Defined in: [calendar-provider.ts:404](https://github.com/epilot-dev/switching-deadlines/blob/3e728b5f762c5b978f43c05453d07a8b73878933/src/calendar-provider.ts#L404)
147125

148126
Counts the number of working days between two dates (inclusive).
149127

@@ -183,7 +161,7 @@ const projectDays = provider.countWorkingDays('2024-01-15', '2024-03-15');
183161

184162
> **getCalendarVersion**(): [`CalendarVersion`](../interfaces/CalendarVersion.md)
185163
186-
Defined in: [calendar-provider.ts:460](https://github.com/epilot-dev/switching-deadlines/blob/6764c18ea2525d949c8b9824eea28bc98b53665e/src/calendar-provider.ts#L460)
164+
Defined in: [calendar-provider.ts:477](https://github.com/epilot-dev/switching-deadlines/blob/3e728b5f762c5b978f43c05453d07a8b73878933/src/calendar-provider.ts#L477)
187165

188166
Gets the current calendar version information.
189167

@@ -207,7 +185,7 @@ console.log(`Last updated: ${version.lastUpdated}`);
207185

208186
> **getDayInfo**(`date`): [`DayInfo`](../interfaces/DayInfo.md)
209187
210-
Defined in: [calendar-provider.ts:235](https://github.com/epilot-dev/switching-deadlines/blob/6764c18ea2525d949c8b9824eea28bc98b53665e/src/calendar-provider.ts#L235)
188+
Defined in: [calendar-provider.ts:252](https://github.com/epilot-dev/switching-deadlines/blob/3e728b5f762c5b978f43c05453d07a8b73878933/src/calendar-provider.ts#L252)
211189

212190
Gets detailed information about a specific day including working day status and holiday information.
213191

@@ -243,7 +221,7 @@ console.log(dayInfo);
243221

244222
> **getNextWorkingDay**(`date`): `Date`
245223
246-
Defined in: [calendar-provider.ts:410](https://github.com/epilot-dev/switching-deadlines/blob/6764c18ea2525d949c8b9824eea28bc98b53665e/src/calendar-provider.ts#L410)
224+
Defined in: [calendar-provider.ts:427](https://github.com/epilot-dev/switching-deadlines/blob/3e728b5f762c5b978f43c05453d07a8b73878933/src/calendar-provider.ts#L427)
247225

248226
Gets the next working day from a given date.
249227

@@ -278,7 +256,7 @@ const afterChristmas = provider.getNextWorkingDay('2024-12-25');
278256

279257
> **getNonWorkingDaysInRange**(`startDate`, `endDate`): [`DayInfo`](../interfaces/DayInfo.md)[]
280258
281-
Defined in: [calendar-provider.ts:351](https://github.com/epilot-dev/switching-deadlines/blob/6764c18ea2525d949c8b9824eea28bc98b53665e/src/calendar-provider.ts#L351)
259+
Defined in: [calendar-provider.ts:368](https://github.com/epilot-dev/switching-deadlines/blob/3e728b5f762c5b978f43c05453d07a8b73878933/src/calendar-provider.ts#L368)
282260

283261
Gets all non-working days (weekends and holidays) between two dates (inclusive).
284262

@@ -321,7 +299,7 @@ nonWorkingDays.forEach(day => {
321299

322300
> **getPreviousWorkingDay**(`date`): `Date`
323301
324-
Defined in: [calendar-provider.ts:437](https://github.com/epilot-dev/switching-deadlines/blob/6764c18ea2525d949c8b9824eea28bc98b53665e/src/calendar-provider.ts#L437)
302+
Defined in: [calendar-provider.ts:454](https://github.com/epilot-dev/switching-deadlines/blob/3e728b5f762c5b978f43c05453d07a8b73878933/src/calendar-provider.ts#L454)
325303

326304
Gets the previous working day from a given date.
327305

@@ -356,7 +334,7 @@ const beforeNewYear = provider.getPreviousWorkingDay('2024-01-02');
356334

357335
> **getWorkingDaysInRange**(`startDate`, `endDate`): [`DayInfo`](../interfaces/DayInfo.md)[]
358336
359-
Defined in: [calendar-provider.ts:312](https://github.com/epilot-dev/switching-deadlines/blob/6764c18ea2525d949c8b9824eea28bc98b53665e/src/calendar-provider.ts#L312)
337+
Defined in: [calendar-provider.ts:329](https://github.com/epilot-dev/switching-deadlines/blob/3e728b5f762c5b978f43c05453d07a8b73878933/src/calendar-provider.ts#L329)
360338

361339
Gets all working days between two dates (inclusive).
362340

@@ -397,7 +375,7 @@ workingDays.forEach(day => {
397375

398376
> **isHoliday**(`date`): `false` \| [`Holiday`](../interfaces/Holiday.md)
399377
400-
Defined in: [calendar-provider.ts:178](https://github.com/epilot-dev/switching-deadlines/blob/6764c18ea2525d949c8b9824eea28bc98b53665e/src/calendar-provider.ts#L178)
378+
Defined in: [calendar-provider.ts:195](https://github.com/epilot-dev/switching-deadlines/blob/3e728b5f762c5b978f43c05453d07a8b73878933/src/calendar-provider.ts#L195)
401379

402380
Checks if a specific date is a holiday.
403381

@@ -432,7 +410,7 @@ const dateHoliday = provider.isHoliday(new Date('2024-01-01'));
432410

433411
> **isWorkingDay**(`date`): `boolean`
434412
435-
Defined in: [calendar-provider.ts:202](https://github.com/epilot-dev/switching-deadlines/blob/6764c18ea2525d949c8b9824eea28bc98b53665e/src/calendar-provider.ts#L202)
413+
Defined in: [calendar-provider.ts:219](https://github.com/epilot-dev/switching-deadlines/blob/3e728b5f762c5b978f43c05453d07a8b73878933/src/calendar-provider.ts#L219)
436414

437415
Checks if a specific date is a working day (not a weekend or holiday).
438416

@@ -464,7 +442,7 @@ const isHoliday = provider.isWorkingDay('2024-12-25'); // false (Christmas)
464442

465443
> **updateCustomHolidays**(`customHolidays`): `void`
466444
467-
Defined in: [calendar-provider.ts:487](https://github.com/epilot-dev/switching-deadlines/blob/6764c18ea2525d949c8b9824eea28bc98b53665e/src/calendar-provider.ts#L487)
445+
Defined in: [calendar-provider.ts:504](https://github.com/epilot-dev/switching-deadlines/blob/3e728b5f762c5b978f43c05453d07a8b73878933/src/calendar-provider.ts#L504)
468446

469447
Updates the custom holidays configuration and clears the holiday cache.
470448

docs/deadlines/deadlines-library/index/classes/DeadlineCalculator.md

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# Class: DeadlineCalculator
88

9-
Defined in: [deadlines-calculator.ts:32](https://github.com/epilot-dev/switching-deadlines/blob/6764c18ea2525d949c8b9824eea28bc98b53665e/src/deadlines-calculator.ts#L32)
9+
Defined in: [deadlines-calculator.ts:47](https://github.com/epilot-dev/switching-deadlines/blob/3e728b5f762c5b978f43c05453d07a8b73878933/src/deadlines-calculator.ts#L47)
1010

1111
Calculator for determining deadline dates and validating start dates for utility switching cases.
1212

@@ -35,39 +35,42 @@ console.log(result.earliestStartDate)
3535

3636
> **new DeadlineCalculator**(`options?`): `DeadlineCalculator`
3737
38-
Defined in: [deadlines-calculator.ts:43](https://github.com/epilot-dev/switching-deadlines/blob/6764c18ea2525d949c8b9824eea28bc98b53665e/src/deadlines-calculator.ts#L43)
38+
Defined in: [deadlines-calculator.ts:68](https://github.com/epilot-dev/switching-deadlines/blob/3e728b5f762c5b978f43c05453d07a8b73878933/src/deadlines-calculator.ts#L68)
3939

4040
Creates a new DeadlineCalculator instance.
4141

4242
#### Parameters
4343

4444
##### options?
4545

46-
Optional configuration options for the calculator
46+
[`DeadlineCalculatorOptions`](../interfaces/DeadlineCalculatorOptions.md)
4747

48-
###### calendarProvider?
49-
50-
[`CalendarProvider`](CalendarProvider.md)
51-
52-
Custom holiday calendar provider
53-
54-
###### customRules?
55-
56-
[`DeadlineRule`](../interfaces/DeadlineRule.md)[]
57-
58-
Override default deadline rules
48+
Optional configuration options for the calculator.
5949

6050
#### Returns
6151

6252
`DeadlineCalculator`
6353

54+
#### Example
55+
56+
```typescript
57+
// Default: built-in calendar + default rules
58+
const calc = new DeadlineCalculator();
59+
60+
// With a custom calendar and rules
61+
const calcCustom = new DeadlineCalculator({
62+
calendarProvider: new CalendarProvider(),
63+
customRules: [], // custom DeadlineRule objects
64+
});
65+
```
66+
6467
## Methods
6568

6669
### calculateEarliestStartDate()
6770

6871
> **calculateEarliestStartDate**(`switchingCase`, `fromDate?`): `object`
6972
70-
Defined in: [deadlines-calculator.ts:72](https://github.com/epilot-dev/switching-deadlines/blob/6764c18ea2525d949c8b9824eea28bc98b53665e/src/deadlines-calculator.ts#L72)
73+
Defined in: [deadlines-calculator.ts:91](https://github.com/epilot-dev/switching-deadlines/blob/3e728b5f762c5b978f43c05453d07a8b73878933/src/deadlines-calculator.ts#L91)
7174

7275
Calculate the earliest possible start date for a contract
7376

@@ -139,7 +142,7 @@ When no applicable rule is found for the switching case
139142

140143
> **getRule**(`switchingCase`): `undefined` \| [`DeadlineRule`](../interfaces/DeadlineRule.md)
141144
142-
Defined in: [deadlines-calculator.ts:201](https://github.com/epilot-dev/switching-deadlines/blob/6764c18ea2525d949c8b9824eea28bc98b53665e/src/deadlines-calculator.ts#L201)
145+
Defined in: [deadlines-calculator.ts:220](https://github.com/epilot-dev/switching-deadlines/blob/3e728b5f762c5b978f43c05453d07a8b73878933/src/deadlines-calculator.ts#L220)
143146

144147
Get a specific rule for a switching case
145148

@@ -166,7 +169,7 @@ The matching deadline rule or undefined if none found
166169

167170
> **getRules**(): [`DeadlineRule`](../interfaces/DeadlineRule.md)[]
168171
169-
Defined in: [deadlines-calculator.ts:185](https://github.com/epilot-dev/switching-deadlines/blob/6764c18ea2525d949c8b9824eea28bc98b53665e/src/deadlines-calculator.ts#L185)
172+
Defined in: [deadlines-calculator.ts:204](https://github.com/epilot-dev/switching-deadlines/blob/3e728b5f762c5b978f43c05453d07a8b73878933/src/deadlines-calculator.ts#L204)
170173

171174
Get all configured rules
172175

@@ -185,7 +188,7 @@ Array of all configured deadline rules
185188

186189
> **validateStartDate**(`switchingCase`, `proposedDate`, `fromDate?`): `object`
187190
188-
Defined in: [deadlines-calculator.ts:148](https://github.com/epilot-dev/switching-deadlines/blob/6764c18ea2525d949c8b9824eea28bc98b53665e/src/deadlines-calculator.ts#L148)
191+
Defined in: [deadlines-calculator.ts:167](https://github.com/epilot-dev/switching-deadlines/blob/3e728b5f762c5b978f43c05453d07a8b73878933/src/deadlines-calculator.ts#L167)
189192

190193
Validate if a proposed start date is valid
191194

0 commit comments

Comments
 (0)