date2obj
date2obj copied to clipboard
seems a bit much...
function date2obj(value) {
var parts = ((value || value === 0) ? new Date(value) : new Date()).toJSON().split(/\D/);
return {
year: parts.shift(),
month: parts.shift(),
day: parts.shift(),
hour: parts.shift(),
minute: parts.shift(),
second: parts.shift(),
millisecond: parts.shift()
}
}
of ...
function date2obj(value) {
const [year, month, day, hour, minute, second, millisecond] =
((value || value === 0) ? new Date(value) : new Date()).toJSON().split(/\D/);
return {year, month, day, hour, minute, second, millisecond};
}
cool! I like this.