Commit 05ba2c3d by François C.

Merge branch '3036-inv-wrong-time' into 'dev_cooperatic'

INV: save UTC time & display according to locale timezone (+ linting)

See merge request !177
parents c1f2b126 9906d8ca
Pipeline #2217 passed with stage
in 1 minute 49 seconds
......@@ -6,7 +6,7 @@ from products.models import CagetteProducts
from inventory.models import CagetteInventory
import os
from datetime import date, datetime
from datetime import date, datetime, timezone
from openpyxl import Workbook
from openpyxl.styles import Alignment, Font
from statistics import *
......@@ -196,7 +196,7 @@ class Shelf(models.Model):
def set_begin_inventory_datetime(self):
res = {}
now = datetime.now().isoformat()
now = datetime.now(timezone.utc).isoformat() # save UTC time
f = {'ongoing_inv_start_datetime': now}
try:
......
......@@ -29,6 +29,13 @@ function init_datatable() {
else {
var date = new Date(data);
// Get local timezone offset in minutes
const offset = date.getTimezoneOffset();
// Add offset to saved time.
// offset is negative if the local time zone is ahead of UTC.
date.setTime(date.getTime() - offset * 60 * 1000);
return `${date.toLocaleDateString('fr-FR')} ${date.toLocaleTimeString('fr-FR')}`;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment