-
Notifications
You must be signed in to change notification settings - Fork 1
/
calendar_dates.js
49 lines (43 loc) · 1005 Bytes
/
calendar_dates.js
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
'use strict'
const {allDay, onWorkingDays, onWeekends} = require('./calendar')
const applyToServices = (services, dates, type) => {
const exceptions = []
for (let service of services) {
for (let date of dates) {
exceptions.push({
service_id: service.service_id,
date,
exception_type: type
})
}
}
return exceptions
}
const laborDay = applyToServices([allDay, onWorkingDays], ['20190501'], '2')
const moreWorkDay = applyToServices([allDay, onWeekends], ['20190615'], '1')
const oneWeekNoService = [].concat(
applyToServices([allDay], [
'20190715',
'20190716',
'20190717',
'20190718',
'20190719',
'20190720',
'20190721'
], '2'),
applyToServices([onWorkingDays], [
'20190715',
'20190716',
'20190717',
'20190718',
'20190719'
], '2'),
applyToServices([onWeekends], [
'20190720',
'20190721'
], '2')
)
const all = [].concat(laborDay, moreWorkDay, oneWeekNoService)
module.exports = Object.assign(all, {
laborDay, moreWorkDay, oneWeekNoService
})