Merge pull request #714 from Hoverbear/hoverbear/times-in-calendar

Calendar: Print times in Calendar
This commit is contained in:
Lemmy
2025-11-11 06:33:26 -05:00
committed by GitHub
+19 -9
View File
@@ -30,6 +30,14 @@ SmartPanel {
return weekNumber
}
// Helper function to check if an event is all-day
function isAllDayEvent(event) {
const duration = event.end - event.start
const startDate = new Date(event.start * 1000)
const isAtMidnight = startDate.getHours() === 0 && startDate.getMinutes() === 0
return duration === 86400 && isAtMidnight
}
panelContent: Item {
anchors.fill: parent
@@ -362,14 +370,6 @@ SmartPanel {
})
}
// Helper function to check if an event is all-day
function isAllDayEvent(event) {
const duration = event.end - event.start
const startDate = new Date(event.start * 1000)
const isAtMidnight = startDate.getHours() === 0 && startDate.getMinutes() === 0
return duration === 86400 && isAtMidnight
}
// Helper function to check if an event is multi-day
function isMultiDayEvent(event) {
if (isAllDayEvent(event)) {
@@ -603,7 +603,17 @@ SmartPanel {
onEntered: {
const events = parent.parent.parent.parent.getEventsForDate(modelData.year, modelData.month, modelData.day)
if (events.length > 0) {
const summaries = events.map(e => e.summary).join('\n')
const summaries = events.map(event => {
if (isAllDayEvent(event)) {
return event.summary
} else {
const start = new Date(event.start * 1000)
const startFormatted = start.toLocaleTimeString(I18n.locale, Locale.ShortFormat)
const end = new Date(event.end * 1000)
const endFormatted = end.toLocaleTimeString(I18n.locale, Locale.ShortFormat)
return `${startFormatted}-${endFormatted} ${event.summary}`
}
}).join('\n')
TooltipService.show(Screen, parent, summaries)
TooltipService.updateText(summaries)
}