-
Notifications
You must be signed in to change notification settings - Fork 31
/
index.d.ts
85 lines (71 loc) · 1.98 KB
/
index.d.ts
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
import * as moment from 'moment-timezone'
interface WeeklySchedule {
sunday?: Schedule
monday?: Schedule
tuesday?: Schedule
wednesday?: Schedule
thursday?: Schedule
friday?: Schedule
saturday?: Schedule
weekdays?: Schedule
unavailability?: Interval[] | ScheduleSpecificDate[]
allocated?: Allocated[]
custom_schedule?: ScheduleSpecificDate[]
}
interface Interval {
from: string | moment.Moment
to: string | moment.Moment
reference?: any
}
export interface ScheduleSpecificDate extends Interval {
date: string | moment.Moment
}
interface Allocated {
from: string | moment.Moment
duration: number
to?: moment.Moment
}
interface Schedule extends Interval {
unavailability?: Interval[]
}
export interface TimeAvailability {
time: string
available: boolean
reference?: any
}
export interface Availability {
[date: string]: TimeAvailability[]
}
interface Params {
from: string | moment.Moment
to: string | moment.Moment
interval: number
duration: number
}
export interface AvailabilityParams extends Params {
schedule: WeeklySchedule
}
export interface IntersectParams extends Params {
schedules: WeeklySchedule[]
}
export class Scheduler {
constructor()
isTimeBefore(first: moment.Moment, second: moment.Moment): boolean
isTimeSameOrAfter(first: moment.Moment, second: moment.Moment): boolean
isTimeAfter(first: moment.Moment, second: moment.Moment): boolean
isTimeslotAvailable(
timeSlotStart: moment.Moment,
timeSlotEnd: moment.Moment,
allocateds: any[]
): boolean
isDateTimeBefore(first: moment.Moment, second: moment.Moment): boolean
isDateTimeSameOrAfter(first: moment.Moment, second: moment.Moment): boolean
isDateTimeAfter(first: moment.Moment, second: moment.Moment): boolean
isDateTimeslotAvailable(
dateSlotStart: moment.Moment,
dateSlotEnd: moment.Moment,
allocateds: any[]
): boolean
getAvailability(params: AvailabilityParams): Availability
getIntersection(params: IntersectParams): Availability
}