Fixed compareDate function for flexible months
This breaks the year layout, but it's 100% caused by the props of the screen, it's not caused by the date comparison
This commit is contained in:
@@ -8,6 +8,7 @@ const { defaultDate, getFormattedDateTitle, getRelativeString } = useCalendar()
|
||||
const { selectedDate } = storeToRefs(useCalendar())
|
||||
|
||||
const mainDateTitle = computed(() => getFormattedDateTitle(selectedDate.value, true))
|
||||
// const mainDateTitle = computed(() => convertDateToDays(selectedDate.value))
|
||||
|
||||
const dateDifference = computed(() => getRelativeString(defaultDate, selectedDate.value))
|
||||
</script>
|
||||
|
||||
@@ -384,20 +384,23 @@ export const useCalendar = defineStore('calendar', () => {
|
||||
/**
|
||||
* Converts a RPGDate to its equivalent in days
|
||||
*
|
||||
* @todo Handle negative dates
|
||||
* @param dateToConvert The date object
|
||||
* @returns How many days does it represent
|
||||
*/
|
||||
function convertDateToDays(dateToConvert: RPGDate): number {
|
||||
// To modify, obviously
|
||||
const daysPerMonth = 32
|
||||
|
||||
let numberOfDays: number = dateToConvert.day
|
||||
|
||||
numberOfDays = numberOfDays + dateToConvert.month * daysPerMonth
|
||||
// Get only the remaining months on the year
|
||||
const validMonths = sortedMonths.value.filter((m) => dateToConvert.month >= m.position)
|
||||
// From remaining months, reduce their days value
|
||||
const monthDaysToAdd = validMonths.reduce((a, b) => {
|
||||
return a + b.days
|
||||
}, 0)
|
||||
|
||||
numberOfDays = numberOfDays + monthDaysToAdd
|
||||
numberOfDays = numberOfDays + dateToConvert.year * daysPerYear.value
|
||||
|
||||
return numberOfDays
|
||||
return numberOfDays - 1
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user