Update duckdb. use more duckdb. Fix the display of stats
This commit is contained in:
@@ -37,20 +37,49 @@ export default class extends Controller {
|
||||
|
||||
// Convert ISO time to local time
|
||||
const date = new Date(timeIso)
|
||||
const localTime = date.toLocaleTimeString(undefined, {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
hour12: false
|
||||
})
|
||||
|
||||
timeElement.textContent = localTime
|
||||
// Determine if we should show date based on time range
|
||||
const now = new Date()
|
||||
const timeDiff = now - date
|
||||
const hoursDiff = timeDiff / (1000 * 60 * 60)
|
||||
|
||||
let displayTime
|
||||
if (hoursDiff > 25) {
|
||||
// For periods longer than 25 hours, show date only (no time)
|
||||
displayTime = date.toLocaleDateString(undefined, {
|
||||
month: 'short',
|
||||
day: 'numeric'
|
||||
})
|
||||
} else {
|
||||
// Check if this is midnight UTC data (daily timeline) vs actual time data (hourly timeline)
|
||||
// Daily timeline: time is at UTC midnight (hours/minutes/seconds = 0)
|
||||
// Hourly timeline: time has actual hours/minutes
|
||||
const utcHours = date.getUTCHours()
|
||||
const utcMinutes = date.getUTCMinutes()
|
||||
const utcSeconds = date.getUTCSeconds()
|
||||
|
||||
if (utcHours === 0 && utcMinutes === 0 && utcSeconds === 0) {
|
||||
// This is midnight UTC - treat as daily data, show date only
|
||||
displayTime = date.toLocaleDateString(undefined, {
|
||||
month: 'short',
|
||||
day: 'numeric'
|
||||
})
|
||||
} else {
|
||||
// This is actual time data - show time only
|
||||
displayTime = date.toLocaleTimeString(undefined, {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
hour12: false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
timeElement.textContent = displayTime
|
||||
timeElement.title = date.toLocaleString(undefined, {
|
||||
weekday: 'short',
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
timeZoneName: 'short'
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user