diff --git a/addons/web/static/src/core/py_js/py_date.js b/addons/web/static/src/core/py_js/py_date.js index 767c6144229..23b439ec438 100644 --- a/addons/web/static/src/core/py_js/py_date.js +++ b/addons/web/static/src/core/py_js/py_date.js @@ -233,9 +233,9 @@ export class PyDate { * @returns {PyDate} */ static convertDate(date) { - const year = date.getUTCFullYear(); - const month = date.getUTCMonth() + 1; - const day = date.getUTCDate(); + const year = date.getFullYear(); + const month = date.getMonth() + 1; + const day = date.getDate(); return new PyDate(year, month, day); } @@ -340,12 +340,12 @@ export class PyDateTime { * @returns {PyDateTime} */ static convertDate(date) { - const year = date.getUTCFullYear(); - const month = date.getUTCMonth() + 1; - const day = date.getUTCDate(); - const hour = date.getUTCHours(); - const minute = date.getUTCMinutes(); - const second = date.getUTCSeconds(); + const year = date.getFullYear(); + const month = date.getMonth() + 1; + const day = date.getDate(); + const hour = date.getHours(); + const minute = date.getMinutes(); + const second = date.getSeconds(); return new PyDateTime(year, month, day, hour, minute, second, 0); } @@ -511,8 +511,8 @@ export class PyTime extends PyDate { constructor(hour, minute, second) { const now = new Date(); const year = now.getFullYear(); - const month = now.getUTCMonth(); - const day = now.getUTCDate(); + const month = now.getMonth(); + const day = now.getDate(); super(year, month, day); this.hour = hour; this.minute = minute; diff --git a/addons/web/static/tests/core/py_js/py_date_tests.js b/addons/web/static/tests/core/py_js/py_date_tests.js index 3e60d970dac..50a219e4ca2 100644 --- a/addons/web/static/tests/core/py_js/py_date_tests.js +++ b/addons/web/static/tests/core/py_js/py_date_tests.js @@ -16,15 +16,15 @@ QUnit.module("py", {}, () => { } const format = (n) => String(n).padStart(2, "0"); const formatDate = (d) => { - const year = d.getUTCFullYear(); - const month = format(d.getUTCMonth() + 1); - const day = format(d.getUTCDate()); + const year = d.getFullYear(); + const month = format(d.getMonth() + 1); + const day = format(d.getDate()); return `${year}-${month}-${day}`; }; const formatDateTime = (d) => { - const h = format(d.getUTCHours()); - const m = format(d.getUTCMinutes()); - const s = format(d.getUTCSeconds()); + const h = format(d.getHours()); + const m = format(d.getMinutes()); + const s = format(d.getSeconds()); return `${formatDate(d)} ${h}:${m}:${s}`; }; @@ -39,12 +39,12 @@ QUnit.module("py", {}, () => { QUnit.module("datetime.datetime"); QUnit.test("datetime.datetime.now", (assert) => { - assert.ok(check("datetime.datetime.now().year", (d) => d.getUTCFullYear())); - assert.ok(check("datetime.datetime.now().month", (d) => d.getUTCMonth() + 1)); - assert.ok(check("datetime.datetime.now().day", (d) => d.getUTCDate())); - assert.ok(check("datetime.datetime.now().hour", (d) => d.getUTCHours())); - assert.ok(check("datetime.datetime.now().minute", (d) => d.getUTCMinutes())); - assert.ok(check("datetime.datetime.now().second", (d) => d.getUTCSeconds())); + assert.ok(check("datetime.datetime.now().year", (d) => d.getFullYear())); + assert.ok(check("datetime.datetime.now().month", (d) => d.getMonth() + 1)); + assert.ok(check("datetime.datetime.now().day", (d) => d.getDate())); + assert.ok(check("datetime.datetime.now().hour", (d) => d.getHours())); + assert.ok(check("datetime.datetime.now().minute", (d) => d.getMinutes())); + assert.ok(check("datetime.datetime.now().second", (d) => d.getSeconds())); }); QUnit.test("various operations", (assert) => {