From 0b51803bcefc15a8bb0e815d022876e3dbc007e4 Mon Sep 17 00:00:00 2001 From: Sergio Crisostomo Date: Tue, 16 Jan 2018 22:25:13 +0100 Subject: [PATCH] Add functions to utils.js --- src/components/date-picker/util.js | 12 ++++++++++++ 1 file changed, 12 insertions(+), 0 deletions(-) diff --git a/src/components/date-picker/util.js b/src/components/date-picker/util.js index 31a10dc..fb248f3 100644 --- a/src/components/date-picker/util.js +++ b/src/components/date-picker/util.js @@ -14,6 +14,18 @@ export const toDate = function(date) { return _date; }; +export const clearHours = function (time) { + const cloneDate = new Date(time); + cloneDate.setHours(0, 0, 0, 0); + return cloneDate.getTime(); +}; + +export const isInRange = (time, a, b) => { + if (!a || !b) return false; + const [start, end] = [a, b].sort(); + return time >= start && time <= end; +}; + export const formatDate = function(date, format) { date = toDate(date); if (!date) return ''; -- libgit2 0.21.4