2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 07:40:55 +00:00

fix: Support JS Date in frappe.format

This commit is contained in:
Faris Ansari 2020-01-28 16:26:44 +05:30
parent 0a401d32cd
commit b00de586cf

View File

@ -25,7 +25,15 @@ module.exports = {
dateFormat = frappe.SystemSettings.dateFormat;
}
value = luxon.DateTime.fromISO(value).toFormat(dateFormat);
if (typeof value === 'string') {
// ISO String
value = luxon.DateTime.fromISO(value);
} else if (Object.prototype.toString.call(value) === '[object Date]') {
// JS Date
value = luxon.DateTime.fromJSDate(value);
}
value = value.toFormat(dateFormat);
if (value === 'Invalid DateTime') {
value = '';
}