Refactor formatLocalTime function in UptimeStatusIsland component to simplify date formatting
- Removed unnecessary comments and adjusted the date format to exclude timezone information. - Enhanced clarity of the function by focusing on local time display without timezone context.
This commit is contained in:
@@ -48,12 +48,10 @@ function getUptime24hBg(uptime) {
|
|||||||
|
|
||||||
function formatLocalTime(rawTime, zone = 'utc') {
|
function formatLocalTime(rawTime, zone = 'utc') {
|
||||||
if (!rawTime) return '';
|
if (!rawTime) return '';
|
||||||
// Parse the API's custom format as UTC
|
|
||||||
const dt = DateTime.fromFormat(rawTime, 'yyyy-MM-dd HH:mm:ss.SSS', { zone: 'utc' });
|
const dt = DateTime.fromFormat(rawTime, 'yyyy-MM-dd HH:mm:ss.SSS', { zone: 'utc' });
|
||||||
// Convert to user's zone if provided and valid
|
|
||||||
const localDt = dt.isValid ? dt.setZone(zone) : null;
|
const localDt = dt.isValid ? dt.setZone(zone) : null;
|
||||||
return localDt && localDt.isValid
|
return localDt && localDt.isValid
|
||||||
? localDt.toFormat('dd-MM-yyyy, HH:mm:ss z')
|
? localDt.toFormat('dd-MM-yyyy, HH:mm:ss')
|
||||||
: 'Invalid DateTime';
|
: 'Invalid DateTime';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user