mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
@@ -72,6 +72,13 @@ data class LocalDate(val daysSince2000: Int) {
|
||||
return dayCache
|
||||
}
|
||||
|
||||
val monthLength: Int
|
||||
get() = when (month) {
|
||||
4, 6, 9, 11 -> 30
|
||||
2 -> if (isLeapYear(year)) 29 else 28
|
||||
else -> 31
|
||||
}
|
||||
|
||||
private fun updateYearMonthDayCache() {
|
||||
var currYear = 2000
|
||||
var currDay = 0
|
||||
|
||||
@@ -248,8 +248,17 @@ open class EntryList {
|
||||
for (i in num - 1 until filtered.size) {
|
||||
val (begin, _) = filtered[i]
|
||||
val (center, _) = filtered[i - num + 1]
|
||||
if (begin.daysUntil(center) < den) {
|
||||
val end = begin.plus(den - 1)
|
||||
var size = den
|
||||
if (den == 30 || den == 31) {
|
||||
val beginDate = begin.toLocalDate()
|
||||
size = if (beginDate.day == beginDate.monthLength) {
|
||||
beginDate.plus(1).monthLength
|
||||
} else {
|
||||
beginDate.monthLength
|
||||
}
|
||||
}
|
||||
if (begin.daysUntil(center) < size) {
|
||||
val end = begin.plus(size - 1)
|
||||
intervals.add(Interval(begin, center, end))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user