mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
Merge pull request #714 from Hoverbear/hoverbear/times-in-calendar
Calendar: Print times in Calendar
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user