Emergency fixes on prod
This commit is contained in:
+27
-14
@@ -619,6 +619,21 @@
|
||||
return date.toISOString().slice(0, 10) + ' ' + date.toISOString().slice(11, 16);
|
||||
}
|
||||
|
||||
function normalizeUtcDateString(dateStr) {
|
||||
let utcDateStr = dateStr;
|
||||
if (!utcDateStr.includes('T')) {
|
||||
utcDateStr = utcDateStr.replace(' ', 'T');
|
||||
}
|
||||
if (!/[zZ]|[+-]\d{2}:\d{2}$/.test(utcDateStr)) {
|
||||
utcDateStr += 'Z';
|
||||
}
|
||||
return utcDateStr;
|
||||
}
|
||||
|
||||
function utcInputToIso(dateStr, timeStr) {
|
||||
return `${dateStr}T${timeStr}:00Z`;
|
||||
}
|
||||
|
||||
// Modal functions
|
||||
function openNewPPRModal() {
|
||||
isNewPPR = true;
|
||||
@@ -755,13 +770,7 @@
|
||||
if (key === 'eta' || key === 'etd') {
|
||||
if (ppr[key]) {
|
||||
// ppr[key] is UTC datetime string from API (naive, assume UTC)
|
||||
let utcDateStr = ppr[key];
|
||||
if (!utcDateStr.includes('T')) {
|
||||
utcDateStr = utcDateStr.replace(' ', 'T');
|
||||
}
|
||||
if (!utcDateStr.includes('Z')) {
|
||||
utcDateStr += 'Z';
|
||||
}
|
||||
const utcDateStr = normalizeUtcDateString(ppr[key]);
|
||||
const date = new Date(utcDateStr); // Now correctly parsed as UTC
|
||||
|
||||
// Split into date and time components for separate inputs
|
||||
@@ -770,15 +779,15 @@
|
||||
|
||||
if (dateField && timeField) {
|
||||
// Format date
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
const year = date.getUTCFullYear();
|
||||
const month = String(date.getUTCMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getUTCDate()).padStart(2, '0');
|
||||
const dateValue = `${year}-${month}-${day}`;
|
||||
dateField.value = dateValue;
|
||||
|
||||
// Format time (round to nearest 15-minute interval)
|
||||
const hours = String(date.getHours()).padStart(2, '0');
|
||||
const rawMinutes = date.getMinutes();
|
||||
const hours = String(date.getUTCHours()).padStart(2, '0');
|
||||
const rawMinutes = date.getUTCMinutes();
|
||||
const roundedMinutes = Math.round(rawMinutes / 15) * 15 % 60;
|
||||
const minutes = String(roundedMinutes).padStart(2, '0');
|
||||
const timeValue = `${hours}:${minutes}`;
|
||||
@@ -1089,12 +1098,16 @@
|
||||
// Combine date and time for ETA
|
||||
const dateStr = formData.get('eta-date');
|
||||
const timeStr = formData.get('eta-time');
|
||||
pprData.eta = new Date(`${dateStr}T${timeStr}`).toISOString();
|
||||
pprData.eta = isNewPPR
|
||||
? new Date(`${dateStr}T${timeStr}`).toISOString()
|
||||
: utcInputToIso(dateStr, timeStr);
|
||||
} else if (key === 'etd-date' && formData.get('etd-time')) {
|
||||
// Combine date and time for ETD
|
||||
const dateStr = formData.get('etd-date');
|
||||
const timeStr = formData.get('etd-time');
|
||||
pprData.etd = new Date(`${dateStr}T${timeStr}`).toISOString();
|
||||
pprData.etd = isNewPPR
|
||||
? new Date(`${dateStr}T${timeStr}`).toISOString()
|
||||
: utcInputToIso(dateStr, timeStr);
|
||||
} else if (key !== 'eta-time' && key !== 'etd-time') {
|
||||
// Skip the time fields as they're handled above
|
||||
pprData[key] = value;
|
||||
|
||||
Reference in New Issue
Block a user