dateData.js
2.18 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
114
115
116
// 自定义时间
let createCustomTime = () => {
let customDate=[]
, obj = {};
let hmsArr = [];
let hours = []
, minutes = []
, seconds = []
, hourObj = {};
for(let h = 0; h < 24; h++) {
let hVal = h + 1;
hVal = hVal > 9 ? hVal : '0' + hVal;
hourObj = {
value: hVal,
children: []
}
for(let m = 0; m < 60; m++) {
let mVal = m + 1;
mVal = mVal > 9 ? mVal : '0' + mVal;
let minutesObj = {
value: mVal,
children: []
};
hourObj.children.push(minutesObj)
for(let s = 0; s < 60; s++) {
let sVal = s + 1;
sVal = sVal > 9 ? sVal : '0' + sVal;
let secondsObj = {
value: sVal
}
hourObj.children[m].children.push(secondsObj)
}
}
hours.push(hourObj)
}
for(let i = 1999; i < 2020; i++) {
obj = {
'value': i + '年',
children: []
}
for(let j = 0; j < 12; j++) {
let val = j + 1;
val = val > 9 ? val : '0' + val;
let obj2 = {
'value': val + '月',
children: []
}
obj.children.push(obj2)
let day = new Date(i, j + 1, 0);
let daycount = day.getDate();
for(let k = 0; k < daycount; k++) {
let val = k + 1;
val = val > 9 ? val : '0' + val;
let obj3 = {
'value': val + '日',
children: []
}
obj3.children = hours;
obj.children[j].children.push(obj3);
}
}
customDate.push(obj)
}
return customDate;
}
// 日级时间
let createDayTime = () => {
let dayDate=[]
, obj = {};
for(let i = 1999; i < 2020; i++) {
obj = {
'value': i + '年',
children: []
}
for(let j = 0; j < 12; j++) {
let val = j + 1;
val = val > 9 ? val : '0' + val;
let obj2 = {
'value': val + '月',
children: []
}
obj.children.push(obj2)
let day = new Date(i, j + 1, 0);
let daycount = day.getDate();
for(let k = 0; k < daycount; k++) {
let val = k + 1;
val = val > 9 ? val : '0' + val;
let obj3 = {
'value': val + '日',
// children: []
}
obj2.children.push(obj3);
}
}
dayDate.push(obj)
}
return dayDate;
}
const _customTime = createCustomTime();
export default {
getCustomTime(cb) {
setTimeout(() => cb(_customTime), 100)
},
getDayTime(cb) {
cb(createDayTime())
},
getStartEndTime(cb) {
cb(createDayTime())
}
}