Commit 0b51803bcefc15a8bb0e815d022876e3dbc007e4
1 parent
ca8e830c
Add functions to utils.js
Showing
1 changed file
with
12 additions
and
0 deletions
Show diff stats
src/components/date-picker/util.js
... | ... | @@ -14,6 +14,18 @@ export const toDate = function(date) { |
14 | 14 | return _date; |
15 | 15 | }; |
16 | 16 | |
17 | +export const clearHours = function (time) { | |
18 | + const cloneDate = new Date(time); | |
19 | + cloneDate.setHours(0, 0, 0, 0); | |
20 | + return cloneDate.getTime(); | |
21 | +}; | |
22 | + | |
23 | +export const isInRange = (time, a, b) => { | |
24 | + if (!a || !b) return false; | |
25 | + const [start, end] = [a, b].sort(); | |
26 | + return time >= start && time <= end; | |
27 | +}; | |
28 | + | |
17 | 29 | export const formatDate = function(date, format) { |
18 | 30 | date = toDate(date); |
19 | 31 | if (!date) return ''; | ... | ... |