-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathCALEXT2_ViewMonth.js
More file actions
43 lines (40 loc) · 1.14 KB
/
CALEXT2_ViewMonth.js
File metadata and controls
43 lines (40 loc) · 1.14 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
/* global dayjs */
/* global ViewCell */
// eslint-disable-next-line no-unused-vars
class ViewMonth extends ViewCell {
getSlotCount () {
const startDay = this.getStartDay();
const endDay = this.getEndWeek();
const diff = endDay.diff(startDay, "week");
return diff + 1;
}
getStartDay () {
const {fromNow} = this.config;
let now = dayjs();
if (this.locale) {
now = now.locale(this.locale);
}
return now.add(fromNow, "month").startOf("month").startOf("week");
}
getEndWeek () {
const {fromNow} = this.config;
let now = dayjs();
if (this.locale) {
now = now.locale(this.locale);
}
return now.add(fromNow, "month").endOf("month").startOf("week");
}
makeSlots () {
super.makeSlots();
if (this.config.monthFormat) {
const {fromNow} = this.config;
let now = dayjs();
if (this.locale) now = now.locale(this.locale);
now.add(fromNow, "month").startOf("month");
const mt = document.createElement("div");
mt.innerHTML = now.format(this.config.monthFormat);
mt.classList.add("monthViewTitle");
this.contentDom.prepend(mt);
}
}
}