fix date formatting when strings are supplied to DatePicker

This commit is contained in:
Sergio Crisostomo 2017-10-23 15:53:12 +02:00
parent b92a1b5c99
commit 65255c9637
3 changed files with 50 additions and 2 deletions

View file

@ -67,6 +67,14 @@ exports.stringToDate = function(str) {
return new Date(...parts);
};
/**
* Transform Date to yyyy-mm-dd string
* @param {Date}
*/
exports.dateToString = function(d) {
return [d.getFullYear(), d.getMonth() + 1, d.getDate()].map(nr => nr > 9 ? nr : '0' + nr).join('-');
};
/**
* 触发一个事件
* mouseenter, mouseleave, mouseover, keyup, change, click