nutritionfactsorg / daily-dozen-android

Keep track of the foods that Dr. Greger recommends in his NYT's best-selling book, How Not to Die with this Android app
https://play.google.com/store/apps/details?id=org.nutritionfacts.dailydozen&hl=en
Other
274 stars 95 forks source link

Reminder shows up at 8 AM instead of 8 PM #198

Closed kartikg3 closed 1 year ago

kartikg3 commented 2 years ago

Same issue as https://github.com/nutritionfactsorg/daily-dozen-android/issues/171

I now have the latest Pixel 6 (Android version 12). Transferred over the data from my LG G6 into a new installation of the app on the Pixel 6, and I still see this issue. I get the reminder at 8 AM in the morning, even if the app shows that it has been set for 8 PM. I am in Canada (EDT) Eastern timezone, if that helps troubleshooting this.

jonasv42 commented 1 year ago

Just tested this on Android version 13 and it worked as expected.

jorpaspr commented 1 year ago

This is reproducible when setting the main language to English (Canada). It does not happen with English (United States) or English (United Kingdom).

jorpaspr commented 1 year ago

Works as expected:

DateFormat twelveHourFormat = new SimpleDateFormat("h:mm a", Locale.US);
twelveHourFormat.parse("8:00 PM");

Throws ParseException, fallbacks to 24h format:

DateFormat twelveHourFormat = new SimpleDateFormat("h:mm a", Locale.CANADA);
twelveHourFormat.parse("8:00 PM");
slavick commented 1 year ago

@jorpaspr Thank you for the info! Everything makes sense now! What a strange issue and compounded by the fact that I cannot get my physical test device nor my emulator to switch to the Canada locale. I've set the timezone manually in both to Canada and Eastern time zone, but the locale still comes back as en_US so I have not been able to test the parse exception directly.

I've created a branch for the fix here: https://github.com/nutritionfactsorg/daily-dozen-android/pull/233

@kartikg3 @jorpaspr Would either of you be willing to test an apk with the above fix to confirm that it works on an actual device?

jorpaspr commented 1 year ago

@slavick This works. I've left a suggestion on the PR as I think it can be improved.

slavick commented 1 year ago

Fix for this bug released in v23.1

https://github.com/nutritionfactsorg/daily-dozen-android/releases/tag/v23.1