Refactor formatLocalTime function in UptimeStatusIsland to remove Luxon fallback
- Eliminated the fallback handling for Luxon in the formatLocalTime function to streamline date formatting. - Improved code clarity by removing unnecessary error handling and debug logging related to Luxon availability. - Maintained existing functionality while simplifying the implementation.
This commit is contained in:
@@ -48,38 +48,6 @@ function getUptime24hBg(uptime) {
|
||||
function formatLocalTime(rawTime, zone = 'utc') {
|
||||
if (!rawTime) return '';
|
||||
|
||||
// Check if Luxon is available
|
||||
if (typeof DateTime === 'undefined') {
|
||||
console.log('PROD DEBUG: Luxon DateTime not available, using fallback');
|
||||
// Fallback to native JavaScript Date
|
||||
try {
|
||||
const date = new Date(rawTime);
|
||||
if (isNaN(date.getTime())) {
|
||||
return 'Invalid DateTime';
|
||||
}
|
||||
|
||||
if (zone === 'utc') {
|
||||
return date.toISOString().slice(0, 19).replace('T', ', ').split('-').reverse().join('-');
|
||||
} else {
|
||||
// Convert to local time
|
||||
const options = {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit',
|
||||
timeZone: zone,
|
||||
hour12: false
|
||||
};
|
||||
return new Intl.DateTimeFormat('en-GB', options).format(date).replace(/\//g, '-');
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('PROD DEBUG: Fallback parsing failed:', e.message);
|
||||
return 'Invalid DateTime';
|
||||
}
|
||||
}
|
||||
|
||||
let dt = null;
|
||||
|
||||
// First try ISO parsing (most reliable for UTC timestamps)
|
||||
|
Reference in New Issue
Block a user