fix of two minor misbehaviors in date-time handling (#3248)

first_day_of_week
Hady 9 months ago committed by GitHub
parent a90b4b510f
commit 70ff2ad79f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -25,7 +25,11 @@ fun DatePickerDialog(
) {
val initialDateUTC by remember(initialDate) {
derivedStateOf {
DateTime(initialDate).toUTC().millis
// DateTime(initialDate).toUTC().millis
// DateTime.toUTC() does not change DateTime.millis value, but DatePicker expects it
// is in local timezone and decrements it by TimeZone.offset. This shifts the date to
// the previous date in timezones to East of GMT, which is unexpected
DateTime(initialDate).let { it.millis + it.offset }
}
}
val datePickerState = rememberDatePickerState(

@ -172,7 +172,11 @@ class CustomRecurrenceViewModel @Inject constructor(
builder.interval(state.interval)
}
when (state.endSelection) {
1 -> builder.until(Date(state.endDate))
// 1 -> builder.until(Date(state.endDate))
// builder.until expects that Date() is in local timezone and strips it, which effectively
// equivalent to decrementing the "endDate" value by TimeZone.offset. This changes the date
// to the previous day in timezones to the East of GMT, so this value shall be pre-shifted
1 -> builder.until(Date(DateTime(state.endDate).let { it.millis + it.offset }))
2 -> builder.count(state.endCount.coerceAtLeast(1))
}
return builder.build().toString()

Loading…
Cancel
Save