UNPKG

lulouis-vant

Version:

Lightweight Mobile UI Components built on Vue

41 lines (31 loc) 859 B
"use strict"; exports.__esModule = true; exports.isValidDate = isValidDate; exports.padZero = padZero; exports.times = times; exports.getTrueValue = getTrueValue; exports.getMonthEndDay = getMonthEndDay; function isValidDate(date) { return Object.prototype.toString.call(date) === '[object Date]' && !isNaN(date.getTime()); } function padZero(val) { return ("00" + val).slice(-2); } function times(n, iteratee) { var index = -1; var result = Array(n); while (++index < n) { result[index] = iteratee(index); } return result; } function getTrueValue(formattedValue) { if (!formattedValue) return; while (isNaN(parseInt(formattedValue, 10))) { formattedValue = formattedValue.slice(1); } return parseInt(formattedValue, 10); } function getMonthEndDay(year, month) { return 32 - new Date(year, month - 1, 32).getDate(); }