Swift 时区标识符列表 🌍

License CocoaPods Compatible Carthage Compatible SwiftPM compatible codecov CI

概述

这个 Swift 库提供了一种便捷的方式,通过 TimeZoneConvertible 协议和 TimeZoneIdentifier 枚举来处理时区。无论您需要当前系统时区、自动更新的时区还是特定的全球时区,这个库都能满足您的需求。

功能

自动更新 🔄

这个库通过 GitHub Actions 设置为每天自动更新时区标识符列表。这些更新与所有 iOS 版本兼容。

该工作流程确保列表保持最新,并且所有更改都直接提交到存储库。只提交差异 (diff),确保更改历史保持清晰且易于跟踪。

安装

Swift 包管理器

将包依赖项添加到您的 Package.swift 文件中

dependencies: [
    .package(url: "https://github.com/nzrsky/TimeZoneIdentifier.git", from: "1.0.0")
]

然后运行

swift build

用法

首先,导入模块

import TimeZoneIdentifiers

使用 TimeZoneConvertible

您可以使用 TimeZoneConvertible 协议在类型之间无缝转换

let timeZone: TimeZone = TimeZoneIdentifier.current.timezone()

使用 TimeZoneIdentifier 枚举

TimeZoneIdentifier 枚举允许您轻松访问不同的时区

let currentZone = TimeZoneIdentifier.current.timezone()
let autoUpdatingZone = TimeZoneIdentifier.autoUpdating.timezone()
let specificZone = TimeZoneIdentifier.africaAbidjan.timezone()

参与贡献

欢迎提交 Pull Request。对于重大更改,请先打开 Issue 讨论您想要更改的内容。

许可证

本项目根据 MIT 许可证获得许可。有关详细信息,请参阅 LICENSE 文件。

由 Alex Nazarov 在 🇱🇻 制作