Add functions to utils.js

This commit is contained in:
Sergio Crisostomo 2018-01-16 22:25:13 +01:00
parent ca8e830cc3
commit 0b51803bce

View file

@ -14,6 +14,18 @@ export const toDate = function(date) {
return _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) { export const formatDate = function(date, format) {
date = toDate(date); date = toDate(date);
if (!date) return ''; if (!date) return '';