Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/usefulness/lazythreetenbp
Maintained fork of a lazy loading ZoneRuleProvider for ThreeTenBp.
https://github.com/usefulness/lazythreetenbp
android iana kotlin lazy threetenabp timezone tzdb
Last synced: about 1 month ago
JSON representation
Maintained fork of a lazy loading ZoneRuleProvider for ThreeTenBp.
- Host: GitHub
- URL: https://github.com/usefulness/lazythreetenbp
- Owner: usefulness
- License: apache-2.0
- Created: 2022-03-25T12:50:49.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2024-04-17T11:18:48.000Z (9 months ago)
- Last Synced: 2024-04-18T06:57:31.988Z (9 months ago)
- Topics: android, iana, kotlin, lazy, threetenabp, timezone, tzdb
- Language: Kotlin
- Homepage: https://github.com/gabrielittner/lazythreetenbp
- Size: 1.05 MB
- Stars: 3
- Watchers: 0
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LazyThreeTenBp
[![Build project](https://github.com/usefulness/lazythreetenbp/actions/workflows/default.yml/badge.svg?branch=master)](https://github.com/usefulness/lazythreetenbp/actions/workflows/default.yml)
![Maven Central](https://img.shields.io/maven-central/v/com.github.usefulness/lazythreetenbp)A lazy loading ZoneRuleProvider for ThreeTenBp.
## Usage
You have to initialize LazyThreeTenBp as early as possible, before your code accesses any threetenbp
class. Usually the best place is in your `Application.onCreate()` method:```kotlin
override fun onCreate() {
super.onCreate()
LazyThreeTen.init(this)
}
```Afterwards you can call `LazyThreeTen.cacheZones()` on a background thread to cache the timezone
information without blocking the startup of your app. If you decide not to do that the individual
timezones will be loaded on demand when they are accessed for the first time.## Download
Add a Gradle dependency:
```groovy
implementation "org.threeten:threetenbp:1.6.0:no-tzdb"
implementation "com.github.usefulness:lazythreetenbp:${version}"
```## Changes
Compiler
- generate java code for list of all timezone ids
- generate a separate .dat file for each zone
- only support one timezone data version at a time (makes some things easier)Runtime
- custom `ZoneRulesProvider`
- provides generated timezone id list
- only reads timezone from assets/disk when that timezone was requested## Update tzdb data
1. Check for the latest tzdb version at https://www.iana.org/time-zones
2. Run `./gradlew generateLazyZoneRules -Plazythreetenbp.tzdbVersion=VERSION`