[improvement] DatetimePicker: jsx (#2510)

This commit is contained in:
neverland
2019-01-12 16:51:51 +08:00
committed by GitHub
parent 2eccc06a2a
commit c68edd388b
2 changed files with 67 additions and 64 deletions

View File

@@ -0,0 +1,29 @@
export function isValidDate(date) {
return Object.prototype.toString.call(date) === '[object Date]' && !isNaN(date.getTime());
}
export function padZero(val) {
return `00${val}`.slice(-2);
}
export function times(n, iteratee) {
let index = -1;
const result = Array(n);
while (++index < n) {
result[index] = iteratee(index);
}
return result;
}
export function getTrueValue(formattedValue) {
if (!formattedValue) return;
while (isNaN(parseInt(formattedValue, 10))) {
formattedValue = formattedValue.slice(1);
}
return parseInt(formattedValue, 10);
}
export function getMonthEndDay(year, month) {
return 32 - new Date(year, month - 1, 32).getDate();
}