Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MaterialDatePicker: Wrong timezone handling #4373

Open
MilosKozak opened this issue Nov 13, 2024 · 1 comment · May be fixed by #4387
Open

MaterialDatePicker: Wrong timezone handling #4373

MilosKozak opened this issue Nov 13, 2024 · 1 comment · May be fixed by #4387

Comments

@MilosKozak
Copy link

MilosKozak commented Nov 13, 2024

Description: When popping up MaterialDatePicker - select current day - press OK in some timezones returns wrong day.
for GMT+1: correct day is returned
for GMT-5: prevoius day is returned
other timezones not tested

Expected behavior: return correct day independent to timezone in phone

Source code:

            MaterialDatePicker.Builder.datePicker()
                .setTheme(app.aaps.core.ui.R.style.DatePicker)
                .build()
                .apply {
                    addOnPositiveButtonClickListener { selection ->
                        val eventTime = selection
...
                    }
                }
               .show(parentFragmentManager, "event_time_date_picker")

Steps to reproduce: Set timezone EST/GMT-5 in phone and pop up dialog, select currend day, press OK, check returned value

https://github.com/nightscout/AndroidAPS/blob/dev/ui/src/main/kotlin/app/aaps/ui/dialogs/DialogFragmentWithDate.kt#L86

Android API version: seems to be independent - more API tested

Material Library version: failing at least for 1.12.0 and 1.13.0-alpha07

Device: seems to be independent - more devices tested

@manabu-nakamura
Copy link
Contributor

            MaterialDatePicker.Builder.datePicker()
                .setTheme(app.aaps.core.ui.R.style.DatePicker)
                .build()
                .apply {
                    addOnPositiveButtonClickListener { selection ->
                        val eventTime = selection
...
                    }
                }
               .show(parentFragmentManager, "event_time_date_picker")

Workaround:

val eventTime = selection - TimeZone.getDefault().rawOffset

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants