-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmodel.ts
More file actions
113 lines (106 loc) · 2.94 KB
/
model.ts
File metadata and controls
113 lines (106 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
export const DAYS_PER_WEEK = 7;
export const ONE_DAY_IN_MILLISECONDS = 24 * 60 * 60 * 1000;
export enum DayOfWeek {
Sunday = 0,
Monday = 1,
Tuesday = 2,
Wednesday = 3,
Thursday = 4,
Friday = 5,
Saturday = 6
}
/**
* The recurrence pattern describes the frequency by which the time window repeats
*/
export enum RecurrencePatternType {
/**
* The pattern where the time window will repeat based on the number of days specified by interval between occurrences
*/
Daily,
/**
* The pattern where the time window will repeat on the same day or days of the week, based on the number of weeks between each set of occurrences
*/
Weekly
}
/**
* The recurrence range specifies the date range over which the time window repeats
*/
export enum RecurrenceRangeType {
/**
* The recurrence has no end and repeats on all the days that fit the corresponding pattern
*/
NoEnd,
/**
* The recurrence repeats on all the days that fit the corresponding pattern until or on the specified end date
*/
EndDate,
/**
* The recurrence repeats for the specified number of occurrences that match the pattern
*/
Numbered
}
/**
* The recurrence pattern describes the frequency by which the time window repeats
*/
export type RecurrencePattern = {
/**
* The type of the recurrence pattern
*/
type: RecurrencePatternType;
/**
* The number of units between occurrences, where units can be in days or weeks, depending on the pattern type
*/
interval: number;
/**
* The days of the week when the time window occurs, which is only applicable for 'Weekly' pattern
*/
daysOfWeek?: DayOfWeek[];
/**
* The first day of the week, which is only applicable for 'Weekly' pattern
*/
firstDayOfWeek?: DayOfWeek;
};
/**
* The recurrence range describes a date range over which the time window repeats
*/
export type RecurrenceRange = {
/**
* The type of the recurrence range
*/
type: RecurrenceRangeType;
/**
* The date to stop applying the recurrence pattern, which is only applicable for 'EndDate' range
*/
endDate?: Date;
/**
* The number of times to repeat the time window, which is only applicable for 'Numbered' range
*/
numberOfOccurrences?: number;
};
/**
* Specification defines the recurring time window
*/
export type RecurrenceSpec = {
/**
* The start time of the first/base time window
*/
startTime: Date;
/**
* The duration of each time window in milliseconds
*/
duration: number;
/**
* The recurrence pattern
*/
pattern: RecurrencePattern;
/**
* The recurrence range
*/
range: RecurrenceRange;
/**
* The timezone offset in milliseconds, which helps to determine the day of week of a given date
*/
timezoneOffset: number;
};