[FIX] website_slides: fix datetimeObj.getTime is not a function
HOW TO REPRODUCE
================
- Don't need to login
- From Odoo front-end, go to Courses > Trees, Wood and Gardens >
Main Trees Categories
- You get the following client error:
Uncaught Promise > datetimeObj.getTime is not a function
HOW TO SOLVE:
============
Unlike standard JS equivalent, luxon datetime objects don't have a
getTime() function. Replace it by valueOf() function.
Also, remove calls to `DateTime.fromJSDate().formatting_fn()` by
luxon equivalent functions.
see bb09cf76e3
task-3632077
closes odoo/odoo#145573
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
import publicWidget from '@web/legacy/js/public/public_widget';
|
||||
import { deserializeDateTime } from "@web/core/l10n/dates";
|
||||
const { DateTime } = luxon;
|
||||
|
||||
publicWidget.registry.websiteSlides = publicWidget.Widget.extend({
|
||||
selector: '#wrapwrap',
|
||||
@@ -20,10 +19,10 @@ publicWidget.registry.websiteSlides = publicWidget.Widget.extend({
|
||||
// if presentation 7 days, 24 hours, 60 min, 60 second, 1000 millis old(one week)
|
||||
// then return fix formate string else timeago
|
||||
var displayStr = '';
|
||||
if (datetimeObj && new Date().getTime() - datetimeObj.getTime() > 7 * 24 * 60 * 60 * 1000) {
|
||||
displayStr = DateTime.fromJSDate(datetimeObj).toFormat('DD');
|
||||
if (datetimeObj && new Date().getTime() - datetimeObj.valueOf() > 7 * 24 * 60 * 60 * 1000) {
|
||||
displayStr = datetimeObj.toFormat('DD');
|
||||
} else {
|
||||
displayStr = DateTime.fromJSDate(datetimeObj).toRelative();
|
||||
displayStr = datetimeObj.toRelative();
|
||||
}
|
||||
$(el).text(displayStr);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user