JakeWharton / ThreeTenABP

An adaptation of the JSR-310 backport for Android.
Apache License 2.0
3.55k stars 133 forks source link

Question: does this library (and probably others) requires constant updating? #80

Closed AndroidDeveloperLB closed 6 years ago

AndroidDeveloperLB commented 6 years ago

It is said in "joda-time" website, that :

The time zone implementation is based on the public tz database, which is updated several times a year

This means, for example, that an app that is based on any time-related library, including here, might get wrong time-related operations if it's not updated by the user?

Is there a way to overcome this? Maybe update just the TZ database from a server (instead of the whole app) ?

What happens to apps that don't use any library, and just use what the API provides? Are they "immune" to this issue ? Does Google somehow update the timezones on the device? If it does, why not use it instead? If it's not, doesn't it mean that a lot of apps might get some time-related operations in the wrong way ?

JakeWharton commented 6 years ago

might get wrong time-related operations if it's not updated by the user?

Yes.

Maybe update just the TZ database from a server (instead of the whole app) ?

You are free to do this, yes. It has nothing to do with this library though. You would use the no-tzdb threetenbp artifact and provide your own mechanism of updating and loading the zone data. This library just repackages the database into assets instead of as a Java resource.

Does Google somehow update the timezones on the device

No. But even if it did...

why not use it instead?

Because it's API 26+

If it's not, doesn't it mean that a lot of apps might get some time-related operations in the wrong way ?

Correct.

AndroidDeveloperLB commented 6 years ago

OK, this can be an issue.

  1. Is there a way to avoid loading the TZ from the library, and do it only from the server that hosts the latest one? Maybe cache it, and load a new one only when there is a one?

  2. Suppose the user use the app only for his own time zone, and we have a server that works only with UTC, will this assumption help in any way? Or there is no way to avoid this, and we would have to load timezones file?

  3. About Google's API, there is also the older API, of Calendar. Thing is that you say they don't update the timezones, so even before, you mean it won't help, right?

  4. How does the calendar app of Google (and others) handle the timezones, then? Do you think they load it from the server too?

JakeWharton commented 6 years ago

I outlined how to do 1 above. The other questions aren't related to this library so I can't help there.

AndroidDeveloperLB commented 6 years ago

About loading the TZ file from server, you mean this: http://www.iana.org/time-zones ?

Will this library (and maybe even the one that it's based on) allow to load the file from there? And which file of there should I use?

image

About code, I think all I need to do is use this:

  ZoneRulesInitializer.setInitializer(...);

And the implementation should be similar to this:

https://github.com/JakeWharton/ThreeTenABP/blob/master/threetenabp/src/main/java/com/jakewharton/threetenabp/AssetsZoneRulesInitializer.java

Right?

Or do I have to do something extra for the file that I get from this server?