zulip / zulip-mobile

Zulip mobile apps for Android and iOS.
https://zulip.com/apps/
Apache License 2.0
1.28k stars 644 forks source link

Respect system 24-hour time setting #4528

Open WesleyAC opened 3 years ago

WesleyAC commented 3 years ago

If the user's system is set to 24-hour time, we should display the time tags on messages and the timezone widgets in 24-hour time.

How to check this: Android iOS

Here's a RN library to do this, I have not made any attempt to evaluate whether it's good or not: react-native-hour-format

abhi0504 commented 3 years ago

@WesleyAC I want to work on this issue can you kindly please assign it to me.

WesleyAC commented 3 years ago

Thanks for taking this on, @abhi0504! Feel free to ping me on chat.zulip.org if you have any questions :)

gnprice commented 3 years ago

I agree.

There is a Zulip user setting for this, and we currently use that -- search for twenty_four_hour_time and twentyFourHourTime. But for a mobile app I think it makes most sense to follow the setting the user has chosen on the device. I just tried several other apps that show times for things, and none of them have their own time-format setting that I can find, and each of them follows the system setting when I change it.

Here's a RN library to do this, I have not made any attempt to evaluate whether it's good or not: react-native-hour-format

It looks probably fine.

It doesn't support a 100% high-quality solution -- it reads this setting at app startup, and then never notices if the user goes and changes it. Apps from Google and Apple, in my testing, do notice immediately if the setting is changed. On Android, the underlying API for this would be to use ContentResolver#registerContentObserver, like in this example: https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/widget/DigitalClock.java#72 and then the library would have to provide a bit of API for the app's JS code to listen in turn. I haven't looked up what API iOS provides for doing this, but I imagine it's fundamentally similar.

That wouldn't be super hard to do... but it would be significantly more work than just using a library like this one. And it doesn't seem like a priority. Few people ever change that setting except when they're first setting up their device, I imagine.

abhi0504 commented 3 years ago

@gnprice Thank you so much for your explanation and ideal solution for the current issue 😊