wip
This commit is contained in:
parent
54c526f548
commit
fded02f5b2
1 changed files with 1 additions and 23 deletions
|
@ -24,12 +24,6 @@ Column {
|
||||||
if (!root.selectedStartDate) return
|
if (!root.selectedStartDate) return
|
||||||
|
|
||||||
if (root.selectedStartDate && root.selectedEndDate) {
|
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
|
// For single date selection, compare with today
|
||||||
const today = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate())
|
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())
|
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() {
|
function resetSelection() {
|
||||||
root.selectedStartDate = new Date()
|
root.selectedStartDate = new Date()
|
||||||
root.selectedEndDate = new Date()
|
root.selectedEndDate = new Date()
|
||||||
|
@ -380,7 +358,7 @@ Column {
|
||||||
if (root.selectedStartDate) {
|
if (root.selectedStartDate) {
|
||||||
root.selectedEndDate = modelData.date
|
root.selectedEndDate = modelData.date
|
||||||
root.hasSelection = true
|
root.hasSelection = true
|
||||||
root.calculateDaysFromReference(root.selectedStartDate, modelData.date)
|
root.calculateDays()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue