This commit is contained in:
pika 2025-06-16 12:19:44 +02:00
parent 54c526f548
commit fded02f5b2

View file

@ -24,12 +24,6 @@ Column {
if (!root.selectedStartDate) return
if (root.selectedStartDate && root.selectedEndDate) {
// For range selection, just count the days between dates
const start = new Date(root.selectedStartDate.getFullYear(), root.selectedStartDate.getMonth(), root.selectedStartDate.getDate())
const end = new Date(root.selectedEndDate.getFullYear(), root.selectedEndDate.getMonth(), root.selectedEndDate.getDate())
const diffDays = Math.round((end - start) / (1000 * 60 * 60 * 24))
root.dateCalculation = Math.abs(diffDays) + " days"
} else {
// For single date selection, compare with today
const today = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate())
const selected = new Date(root.selectedStartDate.getFullYear(), root.selectedStartDate.getMonth(), root.selectedStartDate.getDate())
@ -45,22 +39,6 @@ Column {
}
}
function calculateDaysFromReference(referenceDate, targetDate) {
if (!referenceDate || !targetDate) return
const ref = new Date(referenceDate.getFullYear(), referenceDate.getMonth(), referenceDate.getDate())
const target = new Date(targetDate.getFullYear(), targetDate.getMonth(), targetDate.getDate())
const diffDays = Math.round((target - ref) / (1000 * 60 * 60 * 24))
if (diffDays === 0) {
root.dateCalculation = "0 days"
} else if (diffDays > 0) {
root.dateCalculation = diffDays + " days until"
} else {
root.dateCalculation = Math.abs(diffDays) + " days since"
}
}
function resetSelection() {
root.selectedStartDate = new Date()
root.selectedEndDate = new Date()
@ -380,7 +358,7 @@ Column {
if (root.selectedStartDate) {
root.selectedEndDate = modelData.date
root.hasSelection = true
root.calculateDaysFromReference(root.selectedStartDate, modelData.date)
root.calculateDays()
}
}
}