This Swift library provides a convenient way to handle time zones through the TimeZoneConvertible
protocol and the TimeZoneIdentifier
enum. Whether you need the current system time zone, an auto-updating time zone, or specific global time zones, this library has got you covered.
- Type-safe time zone identifiers.
- Extendable
TimeZoneConvertible
protocol. - Easy-to-use, Swifty API.
This library is set up with GitHub Actions to automatically update the list of time zone identifiers every day. The updates are compatible across all iOS versions.
The workflow ensures that the list stays current, and any changes are committed directly to the repository. Only the differences (diff) are committed, ensuring that the change history remains clean and easy to follow.
Add the package dependency to your Package.swift
file:
dependencies: [
.package(url: "https://github.com/nzrsky/TimeZoneIdentifier.git", from: "1.0.0")
]
Then run:
swift build
First, import the module:
import TimeZoneIdentifiers
You can use the TimeZoneConvertible protocol to seamlessly convert between types:
let timeZone: TimeZone = TimeZoneIdentifier.current.timezone()
The TimeZoneIdentifier enum allows you to easily access different time zones:
let currentZone = TimeZoneIdentifier.current.timezone()
let autoUpdatingZone = TimeZoneIdentifier.autoUpdating.timezone()
let specificZone = TimeZoneIdentifier.africaAbidjan.timezone()
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License. See the LICENSE file for details.
Made in 🇱🇻 by Alex Nazarov