Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #417 from Vishwa-Raghavendra/fix-issue-416
Browse files Browse the repository at this point in the history
Fix issue 416 : Fixed Transactions occurring out of its scope
  • Loading branch information
ILIYANGERMANOV authored Jan 10, 2022
2 parents 0edbfbc + d25b48a commit ac424f8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/com/ivy/wallet/base/DateExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,10 @@ fun LocalDateTime.timeLeft(
}

fun startOfMonth(date: LocalDate): LocalDateTime =
date.withDayOfMonth(1).atStartOfDay()
date.withDayOfMonth(1).atStartOfDay().convertLocalToUTC()

fun endOfMonth(date: LocalDate): LocalDateTime =
date.withDayOfMonth(date.lengthOfMonth()).atEndOfDay()
date.withDayOfMonth(date.lengthOfMonth()).atEndOfDay().convertLocalToUTC()

fun LocalDate.atEndOfDay(): LocalDateTime =
this.atTime(23, 59, 59)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.ivy.wallet.ui.onboarding.model

import android.util.Log
import com.ivy.wallet.base.*
import com.ivy.wallet.ui.theme.modal.model.Month
import java.time.LocalDate
Expand Down Expand Up @@ -43,7 +42,8 @@ data class TimePeriod(
return TimePeriod(
month = Month.fromMonthValue(
periodDate.monthValue
)
),
year = periodDate.year
)
}
}
Expand All @@ -56,7 +56,7 @@ data class TimePeriod(
): FromToTimeRange {
return when {
month != null -> {
val date = if (year!=null) month.toDate().withYear(year) else month.toDate()
val date = if (year != null) month.toDate().withYear(year) else month.toDate()
val (from, to) = if (startDateOfMonth != 1) {
customStartDayOfMonthPeriodRange(
date = date,
Expand Down Expand Up @@ -97,14 +97,16 @@ data class TimePeriod(
val from = date
.withDayOfMonthSafe(startDateOfMonth)
.atStartOfDay()
.convertLocalToUTC()

val to = date
.withDayOfMonthSafe(startDateOfMonth)
//startDayOfMonth != 1 just shift N day the month forward so to should +1 month
.plusMonths(1)
.withDayOfMonthSafe(startDateOfMonth)
//e.g. Correct: 14.10-13.11 (Incorrect: 14.10-14.11)
.minusDays(1)
.atEndOfDay()
.convertLocalToUTC()

return Pair(from, to)
}
Expand All @@ -119,9 +121,7 @@ data class TimePeriod(
} else {
val range = toRange(startDateOfMonth)
val pattern = "MMM dd"
//Don't use formatLocal() because .to is at 23:59:59 =>
// it may appear as +1 day in some timeZones when converted
"${range.from?.format(pattern)} - ${range.to?.format(pattern)}"
"${range.from?.formatLocal(pattern)} - ${range.to?.formatLocal(pattern)}"
}
}
fromToRange != null -> {
Expand Down

0 comments on commit ac424f8

Please sign in to comment.