Skip to content

Commit

Permalink
fix month offset (fixes #5423)
Browse files Browse the repository at this point in the history
  • Loading branch information
westnordost committed Dec 31, 2023
1 parent a69e852 commit 7c52ca9
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,17 @@ class LogsFiltersDialog(
}

private suspend fun pickDate(initialDate: LocalDate): LocalDate =
// LocalDate works with with month *number* (1-12), while Android date picker dialog works
// with month *index*, hence the +1 / -1
suspendCancellableCoroutine { cont ->
DatePickerDialog(
context,
R.style.Theme_Bubble_Dialog_DatePicker,
{ _, year, month, dayOfMonth ->
cont.resume(LocalDate(year, month, dayOfMonth))
{ _, year, monthIndex, dayOfMonth ->
cont.resume(LocalDate(year, monthIndex + 1, dayOfMonth))
},
initialDate.year,
initialDate.monthNumber,
initialDate.monthNumber - 1,
initialDate.dayOfMonth
).show()
}
Expand Down

0 comments on commit 7c52ca9

Please sign in to comment.