iana-time-zone-0.1.53/.cargo_vcs_info.json0000644000000001360000000000100137370ustar { "git": { "sha1": "c6373ec03ed4465487f34c2b7cdff043c2760286" }, "path_in_vcs": "" }iana-time-zone-0.1.53/.clang-format000064400000000000000000000001711046102023000151010ustar 00000000000000--- BasedOnStyle: Google IndentWidth: 4 ColumnLimit: 100 --- Language: Cpp SortIncludes: false TabWidth: 4 UseTab: Never iana-time-zone-0.1.53/.github/dependabot.yml000064400000000000000000000003201046102023000167120ustar 00000000000000version: 2 updates: - package-ecosystem: cargo directory: "/" schedule: interval: daily time: "04:00" open-pull-requests-limit: 10 ignore: - dependency-name: winrt versions: - 0.8.0 iana-time-zone-0.1.53/.github/workflows/rust.yml000064400000000000000000000232431046102023000176500ustar 00000000000000name: build on: push: branches: - main pull_request: branches: [ '**' ] schedule: # At 23:25 on Thursday. - cron: "25 23 * * 4" jobs: test: strategy: fail-fast: false matrix: runs-on: [ubuntu-20.04, windows-2022, macos-12] toolchain: - "1.38" - stable - nightly versions: - "" - "-Zminimal-versions" runs-on: ${{ matrix.runs-on }} steps: - name: Checkout uses: actions/checkout@v3 - uses: maxim-lobanov/setup-xcode@v1 if: matrix.runs-on == 'macos-12' && matrix.toolchain == '1.38' with: xcode-version: "13.4.1" - name: Install Rust id: actions-rs uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: ${{ matrix.toolchain }} override: true - name: Update lockfile run: cargo generate-lockfile ${{ matrix.versions }} env: RUSTC_BOOTSTRAP: 1 - run: cargo test --all-targets - run: cargo run --example stress-test build-wasm: strategy: fail-fast: false matrix: versions: - "" - "-Zminimal-versions" toolchain: - stable - nightly include: # Without `-Zminimal-versions` a too recent bumpalo version is selected. Newer versions use `edition = "2021"`. - versions: "-Zminimal-versions" - toolchain: "1.38" runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - name: Install Rust id: actions-rs uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: ${{ matrix.toolchain }} override: true target: wasm32-unknown-unknown - name: Update lockfile run: cargo generate-lockfile ${{ matrix.versions }} env: RUSTC_BOOTSTRAP: 1 - run: cargo build --lib test-wasm: strategy: fail-fast: false matrix: versions: - "" - "-Zminimal-versions" toolchain: - stable - nightly runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - name: Install Rust id: actions-rs uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: ${{ matrix.toolchain }} override: true target: wasm32-unknown-unknown - name: Install Node uses: actions/setup-node@v3 with: node-version: 14 - name: Update lockfile run: cargo generate-lockfile ${{ matrix.versions }} env: RUSTC_BOOTSTRAP: 1 - run: which wasm-pack || cargo +stable install wasm-pack - run: wasm-pack test --node build-cross: strategy: fail-fast: false matrix: target: - x86_64-unknown-freebsd - x86_64-unknown-illumos - x86_64-unknown-netbsd - x86_64-linux-android - i686-linux-android - arm-linux-androideabi - aarch64-linux-android - sparcv9-sun-solaris versions: - "" - "-Zminimal-versions" toolchain: # There are no docker images for old versions. - stable - nightly runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - name: Install Rust id: actions-rs uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: ${{ matrix.toolchain }} override: true target: ${{ matrix.target }} - name: Update lockfile run: cargo generate-lockfile ${{ matrix.versions }} env: RUSTC_BOOTSTRAP: 1 - run: which cross || cargo +stable install cross - run: cross build --target ${{ matrix.target }} --examples build-ios-cross: strategy: fail-fast: false matrix: toolchain: - "1.38" - stable - nightly target: - aarch64-apple-ios-sim - aarch64-apple-ios - x86_64-apple-ios versions: - "" - "-Zminimal-versions" exclude: # Support for this target was added quite recently. - target: aarch64-apple-ios-sim - toolchain: "1.38" runs-on: macos-12 steps: - name: Checkout uses: actions/checkout@v3 - name: Install Rust id: actions-rs uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: ${{ matrix.toolchain }} override: true target: ${{ matrix.target }} - name: Update lockfile run: cargo generate-lockfile ${{ matrix.versions }} env: RUSTC_BOOTSTRAP: 1 - run: which cross || cargo +stable install cross - run: cross build --target ${{ matrix.target }} --examples check: strategy: fail-fast: false matrix: toolchain: - "1.38" - stable - nightly versions: - "" - "-Zminimal-versions" runs-on: ubuntu-latest env: RUSTFLAGS: -D warnings RUST_BACKTRACE: 1 steps: - name: Checkout uses: actions/checkout@v3 - name: Install Rust id: actions-rs uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: ${{ matrix.toolchain }} override: true components: clippy - name: Update lockfile run: cargo generate-lockfile ${{ matrix.versions }} env: RUSTC_BOOTSTRAP: 1 - run: cargo check --all-targets - run: cargo clippy --all-targets no-docker-image-check-only: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - name: Install Rust id: actions-rs uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: nightly override: true components: rust-src - run: cargo +nightly check --target x86_64-unknown-haiku -Z build-std --examples doc: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - name: Install Rust id: actions-rs uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: nightly override: true - run: RUSTDOCFLAGS="-D warnings" cargo doc --all-features audit: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - name: Audit uses: actions-rs/audit-check@v1 with: token: ${{ secrets.GITHUB_TOKEN }} fallback: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - name: Install Rust id: actions-rs uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: stable target: x86_64-fortanix-unknown-sgx override: true # Should fail (outcome is negated): - run: if cargo build --lib --target x86_64-fortanix-unknown-sgx; then exit 1; fi # Should succeed: - run: cargo build --lib --target x86_64-fortanix-unknown-sgx --features fallback c: name: Lint and format C runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v3 - name: Setup Node.js runtime uses: actions/setup-node@v3 with: node-version: 16 - name: Install npm run: npm i -f -g npm@8.16.0 - name: Lint and check formatting with clang-format run: npx github:artichoke/clang-format --check test-haiku: strategy: fail-fast: false matrix: runs-on: [ubuntu-20.04, windows-2022, macos-12] toolchain: - stable versions: - "" runs-on: ${{ matrix.runs-on }} env: RUSTFLAGS: -D warnings RUST_BACKTRACE: 1 steps: - name: Checkout uses: actions/checkout@v3 - name: Install Rust id: actions-rs uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: ${{ matrix.toolchain }} override: true - name: Update lockfile run: cargo generate-lockfile ${{ matrix.versions }} working-directory: haiku env: RUSTC_BOOTSTRAP: 1 - run: cargo test --all-targets working-directory: haiku check-haiku: strategy: fail-fast: false matrix: toolchain: - stable versions: - "" runs-on: ubuntu-latest env: RUSTFLAGS: -D warnings RUST_BACKTRACE: 1 steps: - name: Checkout uses: actions/checkout@v3 - name: Install Rust id: actions-rs uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: ${{ matrix.toolchain }} override: true components: clippy - name: Update lockfile run: cargo generate-lockfile ${{ matrix.versions }} working-directory: haiku env: RUSTC_BOOTSTRAP: 1 - run: cargo check --all-targets working-directory: haiku - run: cargo clippy --all-targets working-directory: haiku check-all-versions: runs-on: ubuntu-20.04 steps: - name: Checkout uses: actions/checkout@v3 - name: Install Rust id: actions-rs uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: stable override: true - run: which cargo-hack || cargo +stable install cargo-hack - run: cargo hack check --version-range 1.36.. iana-time-zone-0.1.53/.gitignore000064400000000000000000000000221046102023000145110ustar 00000000000000target Cargo.lock iana-time-zone-0.1.53/CHANGELOG.md000064400000000000000000000307371046102023000143520ustar 00000000000000# Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [0.1.53] - 2022-10-28 ### Fixed - remove lint causing breakage on rust 1.45-1.51 ([#84](https://github.com/strawlab/iana-time-zone/pull/84)) ## [0.1.52] - 2022-10-28 ### Fixed - fix for NixOS ([#81](https://github.com/strawlab/iana-time-zone/pull/81)) ### Changed - allow building the haiku crate on other hosts([#75](https://github.com/strawlab/iana-time-zone/pull/75)) - various improvements in continuous integration and source quality ([#76](https://github.com/strawlab/iana-time-zone/pull/76)), ([#77](https://github.com/strawlab/iana-time-zone/pull/77)), ([#78](https://github.com/strawlab/iana-time-zone/pull/78)), ([#81](https://github.com/strawlab/iana-time-zone/pull/81)) ## [0.1.51] - 2022-10-08 ### Changed - bump MSRV to 1.38 ([#70](https://github.com/strawlab/iana-time-zone/pull/70)) - Refactor Android property key CStr construction to add tests ([#69](https://github.com/strawlab/iana-time-zone/pull/69)) - Refactor MacOS implementation a lot ([#67](https://github.com/strawlab/iana-time-zone/pull/67)) ### Added - Implement for Haiku ([#66](https://github.com/strawlab/iana-time-zone/pull/66)) ### Fixed - Fix spelling of 'initialized' in sync::Once statics ([#63](https://github.com/strawlab/iana-time-zone/pull/63)) ## [0.1.50] - 2022-09-23 ### Fixed - Reduce MSRV for Android again ([#62](https://github.com/strawlab/iana-time-zone/pull/62)) ## [0.1.49] - 2022-09-22 ### Changed - `once_cell` dependency is not needed ([#61](https://github.com/strawlab/iana-time-zone/pull/61)) ## [0.1.48] - 2022-09-12 ### Changed - Downgrade requirements for WASM dependencies ([#58](https://github.com/strawlab/iana-time-zone/pull/58)) - Reduce MSRV for Tier 1 platforms to 1.31 ([#59](https://github.com/strawlab/iana-time-zone/pull/59)) ## [0.1.47] - 2022-08-30 ### Changed - Update `android_system_properties` to v0.1.5 to run 9786% faster (YMMV) ([#56](https://github.com/strawlab/iana-time-zone/pull/56)) ## [0.1.46] - 2022-08-18 ### Added - Implement for Solaris ([#55](https://github.com/strawlab/iana-time-zone/pull/55)) ## [0.1.45] - 2022-08-16 ### Fixed - Fix potential use after free in MacOS / iOS ([#54](https://github.com/strawlab/iana-time-zone/pull/54), [RUSTSEC-2022-0049](https://rustsec.org/advisories/RUSTSEC-2022-0049.html)) - Fix typos in README ([#53](https://github.com/strawlab/iana-time-zone/pull/53)) ## [0.1.44] - 2022-08-11 ### Fixed - "/etc/localtime" may be relative link ([#49](https://github.com/strawlab/iana-time-zone/pull/49)) ## [0.1.43] - 2022-08-11 ### Changed - Use `core-foundation-sys` instead of `core-foundation` ([#50](https://github.com/strawlab/iana-time-zone/pull/50)) ## [0.1.42] - 2022-08-10 ### Fixed - Fix implementation for Redhat based distros ([#48](https://github.com/strawlab/iana-time-zone/pull/48)) ## [0.1.41] - 2022-08-02 ### Added - Add `fallback` feature ([#46](https://github.com/strawlab/iana-time-zone/pull/46)) ## [0.1.40] - 2022-07-29 ### Added - Implement for Android ([#45](https://github.com/strawlab/iana-time-zone/pull/45)) ## [0.1.38] - 2022-07-27 ### Added - Implement illumos ([#44](https://github.com/strawlab/iana-time-zone/pull/44)) ### Changed - Update examples in README ## [0.1.37] - 2022-07-23 ### Added - Support iOS ([#41](https://github.com/strawlab/iana-time-zone/pull/41)) ### Changed - Implement `std::err::source()`, format `IoError` ([#42](https://github.com/strawlab/iana-time-zone/pull/42)) ## [0.1.36] - 2022-07-21 ### Fixed - Fail to compile for WASI ([#40](https://github.com/strawlab/iana-time-zone/pull/40)) ## [0.1.35] - 2022-06-29 ### Added - Implement for FreeBSD, NetBSD, OpenBSD and Dragonfly ([#39](https://github.com/strawlab/iana-time-zone/pull/39)) ## [0.1.34] - 2022-06-29 ### Added - Implement for wasm32 ([#38](https://github.com/strawlab/iana-time-zone/pull/38)) ## [0.1.33] - 2022-04-15 ### Changed - Use `winapi` crate instead of `windows` crate ([#35](https://github.com/strawlab/iana-time-zone/pull/35)) ## [0.1.32] - 2022-04-06 ### Changed - Update `windows` requirement from 0.34 to 0.35 ([#34](https://github.com/strawlab/iana-time-zone/pull/34)) ## [0.1.31] - 2022-03-16 ### Changed - Update `windows` requirement from 0.33 to 0.34 ([#33](https://github.com/strawlab/iana-time-zone/pull/33)) ## [0.1.30] - 2022-02-28 ### Changed - Fewer string allocations ([#32](https://github.com/strawlab/iana-time-zone/pull/32)) ## [0.1.29] - 2022-02-25 ### Changed - Update `windows` requirement from 0.32 to 0.33 ([#31](https://github.com/strawlab/iana-time-zone/pull/31)) ## [0.1.28] - 2022-02-04 ### Changed - Update `windows` requirement from 0.30 to 0.32 ([#30](https://github.com/strawlab/iana-time-zone/pull/30)) ## [0.1.27] - 2022-01-14 ### Changed - Update `windows` requirement from 0.29 to 0.30 ([#29](https://github.com/strawlab/iana-time-zone/pull/29)) ## [0.1.26] - 2021-12-23 ### Changed - Update `windows` requirement from 0.28 to 0.29 ([#28](https://github.com/strawlab/iana-time-zone/pull/28)) ## [0.1.25] - 2021-11-18 ### Changed - Update `windows` requirement from 0.27 to 0.28 ([#27](https://github.com/strawlab/iana-time-zone/pull/27)) ## [0.1.24] - 2021-11-16 ### Changed - Update `windows` requirement from 0.26 to 0.27 ([#26](https://github.com/strawlab/iana-time-zone/pull/26)) ## [0.1.23] - 2021-11-12 ### Changed - Update `windows` requirement from 0.25 to 0.26 ([#25](https://github.com/strawlab/iana-time-zone/pull/25)) ## [0.1.22] - 2021-11-08 ### Changed - Update `windows` requirement from 0.24 to 0.25 ([#24](https://github.com/strawlab/iana-time-zone/pull/24)) ## [0.1.21] - 2021-11-02 ### Changed - Update `windows` requirement from 0.23 to 0.24 ([#23](https://github.com/strawlab/iana-time-zone/pull/23)) ## [0.1.20] - 2021-10-29 ### Changed - Update `windows` requirement from 0.21 to 0.23 ([#22](https://github.com/strawlab/iana-time-zone/pull/22)) ## [0.1.19] - 2021-09-27 ### Changed - Update `windows` requirement from 0.19 to 0.21 ([#18](https://github.com/strawlab/iana-time-zone/pull/18), [#20](https://github.com/strawlab/iana-time-zone/pull/20)) - Update `chrono-tz` requirement from 0.5 to 0.6 ([#19](https://github.com/strawlab/iana-time-zone/pull/19)) ## [0.1.18] - 2021-08-23 ### Changed - Update `windows` requirement from 0.18 to 0.19 ([#17](https://github.com/strawlab/iana-time-zone/pull/17)) ## [0.1.16] - 2021-07-26 ### Changed - Update `windows` requirement from 0.17 to 0.18 ([#16](https://github.com/strawlab/iana-time-zone/pull/16)) ## [0.1.15] - 2021-07-08 ### Changed - Update `windows` requirement from 0.14 to 0.17 ([#15](https://github.com/strawlab/iana-time-zone/pull/15)) ## [0.1.14] - 2021-07-07 ### Changed - Update `windows` requirement from 0.13 to 0.14 ([#14](https://github.com/strawlab/iana-time-zone/pull/14)) ## [0.1.13] - 2021-06-28 ### Changed - Update `windows` requirement from 0.12 to 0.13 ([#13](https://github.com/strawlab/iana-time-zone/pull/13)) ## [0.1.12] - 2021-06-28 ### Changed - Update `windows` requirement from 0.11 to 0.12 ([#12](https://github.com/strawlab/iana-time-zone/pull/12)) ## [0.1.11] - 2021-06-12 ### Changed - Update `windows` requirement from 0.10 to 0.11 ([#11](https://github.com/strawlab/iana-time-zone/pull/11)) ## [0.1.10] - 2021-05-13 ### Changed - Update `windows` requirement from 0.9 to 0.10 ([#10](https://github.com/strawlab/iana-time-zone/pull/10)) ## [0.1.9] - 2021-04-28 ### Changed - Update `windows` requirement from 0.8 to 0.9 ([#8](https://github.com/strawlab/iana-time-zone/pull/8)) ## [0.1.8] - 2021-04-13 ### Changed - Update `windows` requirement from 0.7 to 0.8 ([#7](https://github.com/strawlab/iana-time-zone/pull/7)) ## [0.1.7] - 2021-03-30 ### Changed - Update `windows` requirement from 0.6 to 0.7 ([#6](https://github.com/strawlab/iana-time-zone/pull/6)) ## [0.1.6] - 2021-03-24 ### Changed - Update `windows` requirement from 0.5 to 0.6 ([#5](https://github.com/strawlab/iana-time-zone/pull/5)) ## [0.1.5] - 2021-03-20 ### Changed - Update `windows` requirement from 0.4 to 0.5 ([#4](https://github.com/strawlab/iana-time-zone/pull/4)) ## [0.1.4] - 2021-03-11 ### Changed - Update `windows` requirement from 0.3 to 0.4 ([#3](https://github.com/strawlab/iana-time-zone/pull/3)) ## [0.1.3] - 2021-02-22 ### Changed - Use `windows` crate instead of `winrt` ## [0.1.2] - 2020-10-09 ### Changed - Update `core-foundation` requirement from 0.7 to 0.9 ([#1](https://github.com/strawlab/iana-time-zone/pull/1)) ## [0.1.1] - 2020-06-27 ### Changed - Update `core-foundation` requirement from 0.5 to 0.7 ## [0.1.0] - 2020-06-27 ### Added - Implement for Linux, Windows, MacOS [0.1.53]: https://github.com/strawlab/iana-time-zone/releases/tag/v0.1.53 [0.1.52]: https://github.com/strawlab/iana-time-zone/releases/tag/v0.1.52 [0.1.51]: https://github.com/strawlab/iana-time-zone/releases/tag/v0.1.51 [0.1.50]: https://github.com/strawlab/iana-time-zone/releases/tag/v0.1.50 [0.1.49]: https://github.com/strawlab/iana-time-zone/releases/tag/v0.1.49 [0.1.48]: https://github.com/strawlab/iana-time-zone/releases/tag/v0.1.48 [0.1.47]: https://github.com/strawlab/iana-time-zone/releases/tag/v0.1.47 [0.1.46]: https://github.com/strawlab/iana-time-zone/releases/tag/v0.1.46 [0.1.45]: https://github.com/strawlab/iana-time-zone/releases/tag/v0.1.45 [0.1.44]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.44 [0.1.43]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.43 [0.1.42]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.42 [0.1.41]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.41 [0.1.40]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.40 [0.1.39]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.39 [0.1.38]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.38 [0.1.37]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.37 [0.1.36]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.36 [0.1.35]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.35 [0.1.34]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.34 [0.1.33]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.33 [0.1.32]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.32 [0.1.31]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.31 [0.1.30]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.30 [0.1.29]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.29 [0.1.28]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.28 [0.1.27]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.27 [0.1.26]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.26 [0.1.25]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.25 [0.1.24]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.24 [0.1.23]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.23 [0.1.22]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.22 [0.1.21]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.21 [0.1.20]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.20 [0.1.19]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.19 [0.1.18]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.18 [0.1.17]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.17 [0.1.16]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.16 [0.1.15]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.15 [0.1.14]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.14 [0.1.13]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.13 [0.1.12]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.12 [0.1.11]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.11 [0.1.10]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.10 [0.1.9]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.9 [0.1.8]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.8 [0.1.7]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.7 [0.1.6]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.6 [0.1.5]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.5 [0.1.4]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.4 [0.1.3]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.3 [0.1.2]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.2 [0.1.1]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.1 [0.1.0]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.0 iana-time-zone-0.1.53/Cargo.lock0000644000000220540000000000100117150ustar # This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 [[package]] name = "android_system_properties" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" dependencies = [ "libc", ] [[package]] name = "bumpalo" version = "3.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" [[package]] name = "cc" version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "codespan-reporting" version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" dependencies = [ "termcolor", "unicode-width", ] [[package]] name = "console_error_panic_hook" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" dependencies = [ "cfg-if", "wasm-bindgen", ] [[package]] name = "core-foundation-sys" version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" [[package]] name = "cxx" version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b7d4e43b25d3c994662706a1d4fcfc32aaa6afd287502c111b237093bb23f3a" dependencies = [ "cc", "cxxbridge-flags", "cxxbridge-macro", "link-cplusplus", ] [[package]] name = "cxx-build" version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "84f8829ddc213e2c1368e51a2564c552b65a8cb6a28f31e576270ac81d5e5827" dependencies = [ "cc", "codespan-reporting", "once_cell", "proc-macro2", "quote", "scratch", "syn", ] [[package]] name = "cxxbridge-flags" version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e72537424b474af1460806647c41d4b6d35d09ef7fe031c5c2fa5766047cc56a" [[package]] name = "cxxbridge-macro" version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "309e4fb93eed90e1e14bea0da16b209f81813ba9fc7830c20ed151dd7bc0a4d7" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "iana-time-zone" version = "0.1.53" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", "wasm-bindgen-test", "winapi", ] [[package]] name = "iana-time-zone-haiku" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" dependencies = [ "cxx", "cxx-build", ] [[package]] name = "js-sys" version = "0.3.60" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" dependencies = [ "wasm-bindgen", ] [[package]] name = "libc" version = "0.2.137" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" [[package]] name = "link-cplusplus" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369" dependencies = [ "cc", ] [[package]] name = "log" version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" dependencies = [ "cfg-if", ] [[package]] name = "once_cell" version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" [[package]] name = "proc-macro2" version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" dependencies = [ "unicode-ident", ] [[package]] name = "quote" version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" dependencies = [ "proc-macro2", ] [[package]] name = "scoped-tls" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" [[package]] name = "scratch" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" [[package]] name = "syn" version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "termcolor" version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" dependencies = [ "winapi-util", ] [[package]] name = "unicode-ident" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" [[package]] name = "unicode-width" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" [[package]] name = "wasm-bindgen" version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" dependencies = [ "cfg-if", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", "syn", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" version = "0.4.33" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23639446165ca5a5de86ae1d8896b737ae80319560fbaa4c2887b7da6e7ebd7d" dependencies = [ "cfg-if", "js-sys", "wasm-bindgen", "web-sys", ] [[package]] name = "wasm-bindgen-macro" version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" dependencies = [ "quote", "wasm-bindgen-macro-support", ] [[package]] name = "wasm-bindgen-macro-support" version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" dependencies = [ "proc-macro2", "quote", "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" [[package]] name = "wasm-bindgen-test" version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09d2fff962180c3fadf677438054b1db62bee4aa32af26a45388af07d1287e1d" dependencies = [ "console_error_panic_hook", "js-sys", "scoped-tls", "wasm-bindgen", "wasm-bindgen-futures", "wasm-bindgen-test-macro", ] [[package]] name = "wasm-bindgen-test-macro" version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4683da3dfc016f704c9f82cf401520c4f1cb3ee440f7f52b3d6ac29506a49ca7" dependencies = [ "proc-macro2", "quote", ] [[package]] name = "web-sys" version = "0.3.60" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f" dependencies = [ "js-sys", "wasm-bindgen", ] [[package]] name = "winapi" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ "winapi-i686-pc-windows-gnu", "winapi-x86_64-pc-windows-gnu", ] [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" dependencies = [ "winapi", ] [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" iana-time-zone-0.1.53/Cargo.toml0000644000000033270000000000100117420ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2018" name = "iana-time-zone" version = "0.1.53" authors = [ "Andrew Straw ", "René Kijewski ", "Ryan Lopopolo ", ] description = "get the IANA time zone for the current system" readme = "README.md" keywords = [ "IANA", "time", ] categories = [ "date-and-time", "internationalization", "os", ] license = "MIT OR Apache-2.0" repository = "https://github.com/strawlab/iana-time-zone" [features] fallback = [] [target."cfg(any(target_os = \"macos\", target_os = \"ios\"))".dependencies.core-foundation-sys] version = "0.8.3" [target."cfg(target_arch = \"wasm32\")".dependencies.js-sys] version = "0.3.50" [target."cfg(target_arch = \"wasm32\")".dependencies.wasm-bindgen] version = "0.2.70" [target."cfg(target_arch = \"wasm32\")".dev-dependencies.wasm-bindgen-test] version = "0.3" [target."cfg(target_os = \"android\")".dependencies.android_system_properties] version = "0.1.5" [target."cfg(target_os = \"haiku\")".dependencies.iana-time-zone-haiku] version = "0.1.1" [target."cfg(target_os = \"windows\")".dependencies.winapi] version = "0.3.9" features = [ "activation", "combaseapi", "objbase", "roapi", "winerror", "winstring", ] iana-time-zone-0.1.53/Cargo.toml.orig000064400000000000000000000025161046102023000154220ustar 00000000000000[package] name = "iana-time-zone" description = "get the IANA time zone for the current system" version = "0.1.53" authors = [ "Andrew Straw ", "René Kijewski ", "Ryan Lopopolo ", ] repository = "https://github.com/strawlab/iana-time-zone" license = "MIT OR Apache-2.0" keywords = ["IANA", "time"] categories = ["date-and-time", "internationalization", "os"] readme = "README.md" edition = "2018" [features] # When enabled, the library will succeed to compile for unknown target platforms, and return an `Err(GetTimezoneError::OsError)` at runtime. fallback = [] [target.'cfg(target_os = "android")'.dependencies] android_system_properties = "0.1.5" [target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies] core-foundation-sys = "0.8.3" [target.'cfg(target_os = "windows")'.dependencies] winapi = { version = "0.3.9", features = ["activation", "combaseapi", "objbase", "roapi", "winerror", "winstring"] } [target.'cfg(target_arch = "wasm32")'.dependencies] js-sys = "0.3.50" wasm-bindgen = "0.2.70" [target.'cfg(target_arch = "wasm32")'.dev-dependencies] wasm-bindgen-test = "0.3" [target.'cfg(target_os = "haiku")'.dependencies] iana-time-zone-haiku = { version = "0.1.1", path = "haiku" } [workspace] members = [".", "haiku"] default-members = ["."] iana-time-zone-0.1.53/LICENSE-APACHE000064400000000000000000000251201046102023000144530ustar 00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright 2020 Andrew Straw Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. iana-time-zone-0.1.53/LICENSE-MIT000064400000000000000000000020431046102023000141620ustar 00000000000000Copyright (c) 2020 Andrew D. Straw Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. iana-time-zone-0.1.53/README.md000064400000000000000000000034721046102023000140140ustar 00000000000000# iana-time-zone - get the IANA time zone for the current system [![Crates.io](https://img.shields.io/crates/v/iana-time-zone.svg)](https://crates.io/crates/iana-time-zone) [![Documentation](https://docs.rs/iana-time-zone/badge.svg)](https://docs.rs/iana-time-zone/) [![Crate License](https://img.shields.io/crates/l/iana-time-zone.svg)](https://crates.io/crates/iana-time-zone) [![build](https://github.com/strawlab/iana-time-zone/workflows/build/badge.svg?branch=master)](https://github.com/strawlab/iana-time-zone/actions?query=branch%3Amaster) This small utility crate gets the IANA time zone for the current system. This is also known the [tz database](https://en.wikipedia.org/wiki/Tz_database), tzdata, the zoneinfo database, and the Olson database. Example: ```rust // Get the current time zone as a string. let tz_str = iana_time_zone::get_timezone()?; println!("The current time zone is: {}", tz_str); ``` You can test this is working on your platform with: ``` cargo run --example get_timezone ``` ## Minimum supported rust version policy This crate has a minimum supported rust version (MSRV) of 1.38 for [Tier 1](https://doc.rust-lang.org/1.63.0/rustc/platform-support.html) platforms. Updates to the MSRV are sometimes necessary due to the MSRV of dependencies. MSRV updates will not be indicated as a breaking change to the semver version. ## License Licensed under either of * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or ) * MIT license ([LICENSE-MIT](LICENSE-MIT) or ) at your option. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. iana-time-zone-0.1.53/examples/get_timezone.rs000064400000000000000000000002251046102023000174030ustar 00000000000000use iana_time_zone::{get_timezone, GetTimezoneError}; fn main() -> Result<(), GetTimezoneError> { println!("{}", get_timezone()?); Ok(()) } iana-time-zone-0.1.53/examples/stress-test.rs000064400000000000000000000012041046102023000172100ustar 00000000000000use std::sync::atomic::{AtomicUsize, Ordering}; use std::thread::spawn; use iana_time_zone::get_timezone; const THREADS: usize = 10; const ITERATIONS: usize = 100_000; static COUNT: AtomicUsize = AtomicUsize::new(0); fn main() { let mut threads = Vec::with_capacity(THREADS); for _ in 0..THREADS { threads.push(spawn(|| { for _ in 0..ITERATIONS { get_timezone().unwrap(); COUNT.fetch_add(1, Ordering::Relaxed); } })); } for thread in threads { thread.join().unwrap(); } assert_eq!(COUNT.load(Ordering::SeqCst), THREADS * ITERATIONS); } iana-time-zone-0.1.53/src/ffi_utils.rs000064400000000000000000000034221046102023000156510ustar 00000000000000//! Cross platform FFI helpers. use std::ffi::CStr; // The system property named 'persist.sys.timezone' contains the name of the // current timezone. // // From https://android.googlesource.com/platform/bionic/+/gingerbread-release/libc/docs/OVERVIEW.TXT#79: // // > The name of the current timezone is taken from the TZ environment variable, // > if defined. Otherwise, the system property named 'persist.sys.timezone' is // > checked instead. const ANDROID_TIMEZONE_PROPERTY_NAME: &[u8] = b"persist.sys.timezone\0"; /// Return a [`CStr`] to access the timezone from an Android system properties /// environment. pub(crate) fn android_timezone_property_name() -> &'static CStr { // In tests or debug mode, opt into extra runtime checks. if cfg!(any(test, debug_assertions)) { return CStr::from_bytes_with_nul(ANDROID_TIMEZONE_PROPERTY_NAME).unwrap(); } // SAFETY: the key is NUL-terminated and there are no other NULs, this // invariant is checked in tests. unsafe { CStr::from_bytes_with_nul_unchecked(ANDROID_TIMEZONE_PROPERTY_NAME) } } #[cfg(test)] mod tests { use std::ffi::CStr; use super::{android_timezone_property_name, ANDROID_TIMEZONE_PROPERTY_NAME}; #[test] fn test_android_timezone_property_name_is_valid_cstr() { CStr::from_bytes_with_nul(ANDROID_TIMEZONE_PROPERTY_NAME).unwrap(); let mut invalid_property_name = ANDROID_TIMEZONE_PROPERTY_NAME.to_owned(); invalid_property_name.push(b'\0'); CStr::from_bytes_with_nul(&invalid_property_name).unwrap_err(); } #[test] fn test_android_timezone_property_name_getter() { let key = android_timezone_property_name().to_bytes_with_nul(); assert_eq!(key, ANDROID_TIMEZONE_PROPERTY_NAME); std::str::from_utf8(key).unwrap(); } } iana-time-zone-0.1.53/src/lib.rs000064400000000000000000000062661046102023000144440ustar 00000000000000#![warn(clippy::all)] #![warn(clippy::cargo)] #![warn(clippy::undocumented_unsafe_blocks)] #![allow(unknown_lints)] #![warn(missing_copy_implementations)] #![warn(missing_debug_implementations)] #![warn(missing_docs)] #![warn(rust_2018_idioms)] #![warn(trivial_casts, trivial_numeric_casts)] #![warn(unused_qualifications)] #![warn(variant_size_differences)] //! get the IANA time zone for the current system //! //! This small utility crate provides the //! [`get_timezone()`](fn.get_timezone.html) function. //! //! ```rust //! // Get the current time zone as a string. //! let tz_str = iana_time_zone::get_timezone()?; //! println!("The current time zone is: {}", tz_str); //! # Ok::<(), iana_time_zone::GetTimezoneError>(()) //! ``` //! //! The resulting string can be parsed to a //! [`chrono-tz::Tz`](https://docs.rs/chrono-tz/latest/chrono_tz/enum.Tz.html) //! variant like this: //! ```ignore //! let tz_str = iana_time_zone::get_timezone()?; //! let tz: chrono_tz::Tz = tz_str.parse()?; //! ``` #[allow(dead_code)] mod ffi_utils; #[cfg_attr(target_os = "linux", path = "tz_linux.rs")] #[cfg_attr(target_os = "windows", path = "tz_windows.rs")] #[cfg_attr(any(target_os = "macos", target_os = "ios"), path = "tz_macos.rs")] #[cfg_attr( all(target_arch = "wasm32", not(target_os = "wasi")), path = "tz_wasm32.rs" )] #[cfg_attr( any(target_os = "freebsd", target_os = "dragonfly"), path = "tz_freebsd.rs" )] #[cfg_attr( any(target_os = "netbsd", target_os = "openbsd"), path = "tz_netbsd.rs" )] #[cfg_attr( any(target_os = "illumos", target_os = "solaris"), path = "tz_illumos.rs" )] #[cfg_attr(target_os = "android", path = "tz_android.rs")] #[cfg_attr(target_os = "haiku", path = "tz_haiku.rs")] mod platform; /// Error types #[derive(Debug)] pub enum GetTimezoneError { /// Failed to parse FailedParsingString, /// Wrapped IO error IoError(std::io::Error), /// Platform-specific error from the operating system OsError, } impl std::error::Error for GetTimezoneError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { match self { GetTimezoneError::FailedParsingString => None, GetTimezoneError::IoError(err) => Some(err), GetTimezoneError::OsError => None, } } } impl std::fmt::Display for GetTimezoneError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { f.write_str(match self { GetTimezoneError::FailedParsingString => "GetTimezoneError::FailedParsingString", GetTimezoneError::IoError(err) => return err.fmt(f), GetTimezoneError::OsError => "OsError", }) } } impl From for GetTimezoneError { fn from(orig: std::io::Error) -> Self { GetTimezoneError::IoError(orig) } } /// Get the current IANA time zone as a string. /// /// See the module-level documentatation for a usage example and more details /// about this function. #[inline] pub fn get_timezone() -> Result { platform::get_timezone_inner() } #[cfg(test)] mod tests { use super::*; #[test] fn get_current() { println!("current: {}", get_timezone().unwrap()); } } iana-time-zone-0.1.53/src/platform.rs000064400000000000000000000005551046102023000155150ustar 00000000000000pub fn get_timezone_inner() -> std::result::Result { Err(crate::GetTimezoneError::OsError) } #[cfg(not(feature = "fallback"))] compile_error!( "iana-time-zone is currently implemented for Linux, Window, MacOS, FreeBSD, NetBSD, \ OpenBSD, Dragonfly, WebAssembly (browser), iOS, Illumos, Android, Solaris and Haiku.", ); iana-time-zone-0.1.53/src/tz_android.rs000064400000000000000000000016501046102023000160230ustar 00000000000000use std::sync::Once; use android_system_properties::AndroidSystemProperties; use crate::ffi_utils::android_timezone_property_name; pub(crate) fn get_timezone_inner() -> Result { let key = android_timezone_property_name(); get_properties() .and_then(|properties| properties.get_from_cstr(key)) .ok_or(crate::GetTimezoneError::OsError) } fn get_properties() -> Option<&'static AndroidSystemProperties> { static INITIALIZED: Once = Once::new(); static mut PROPERTIES: Option = None; INITIALIZED.call_once(|| { let properties = AndroidSystemProperties::new(); // SAFETY: `INITIALIZED` is synchronizing. The variable is only assigned to once. unsafe { PROPERTIES = Some(properties) }; }); // SAFETY: `INITIALIZED` is synchronizing. The variable is only assigned to once. unsafe { PROPERTIES.as_ref() } } iana-time-zone-0.1.53/src/tz_freebsd.rs000064400000000000000000000005341046102023000160150ustar 00000000000000pub(crate) fn get_timezone_inner() -> Result { // see https://gitlab.gnome.org/GNOME/evolution-data-server/-/issues/19 let mut contents = std::fs::read_to_string("/var/db/zoneinfo")?; // Trim to the correct length without allocating. contents.truncate(contents.trim_end().len()); Ok(contents) } iana-time-zone-0.1.53/src/tz_haiku.rs000064400000000000000000000002431046102023000155010ustar 00000000000000pub(crate) fn get_timezone_inner() -> Result { iana_time_zone_haiku::get_timezone().ok_or(crate::GetTimezoneError::OsError) } iana-time-zone-0.1.53/src/tz_illumos.rs000064400000000000000000000014371046102023000160720ustar 00000000000000use std::fs::OpenOptions; use std::io::{BufRead, BufReader}; pub(crate) fn get_timezone_inner() -> Result { // https://illumos.org/man/5/TIMEZONE // https://docs.oracle.com/cd/E23824_01/html/821-1473/uc-timezone-4.html let file = OpenOptions::new().read(true).open("/etc/default/init")?; let mut reader = BufReader::with_capacity(1536, file); let mut line = String::with_capacity(80); loop { line.clear(); let count = reader.read_line(&mut line)?; if count == 0 { return Err(crate::GetTimezoneError::FailedParsingString); } else if line.starts_with("TZ=") { line.truncate(line.trim_end().len()); line.replace_range(..3, ""); return Ok(line); } } } iana-time-zone-0.1.53/src/tz_linux.rs000064400000000000000000000037751046102023000155540ustar 00000000000000use std::fs::{read_link, read_to_string}; pub(crate) fn get_timezone_inner() -> Result { etc_localtime().or_else(|_| etc_timezone()) } fn etc_timezone() -> Result { // see https://stackoverflow.com/a/12523283 let mut contents = read_to_string("/etc/timezone")?; // Trim to the correct length without allocating. contents.truncate(contents.trim_end().len()); Ok(contents) } fn etc_localtime() -> Result { // Per : // “ The /etc/localtime file configures the system-wide timezone of the local system that is // used by applications for presentation to the user. It should be an absolute or relative // symbolic link pointing to /usr/share/zoneinfo/, followed by a timezone identifier such as // "Europe/Berlin" or "Etc/UTC". The resulting link should lead to the corresponding binary // tzfile(5) timezone data for the configured timezone. ” // Systemd does not canonicalize the link, but only checks if it is prefixed by // "/usr/share/zoneinfo/" or "../usr/share/zoneinfo/". So we do the same. // const PREFIXES: &[&str] = &[ "/usr/share/zoneinfo/", // absolute path "../usr/share/zoneinfo/", // relative path "/etc/zoneinfo/", // absolute path for NixOS "../etc/zoneinfo/", // relative path for NixOS ]; let mut s = read_link("/etc/localtime")? .into_os_string() .into_string() .map_err(|_| crate::GetTimezoneError::FailedParsingString)?; for &prefix in PREFIXES { if s.starts_with(prefix) { // Trim to the correct length without allocating. s.replace_range(..prefix.len(), ""); return Ok(s); } } Err(crate::GetTimezoneError::FailedParsingString) } iana-time-zone-0.1.53/src/tz_macos.rs000064400000000000000000000115441046102023000155100ustar 00000000000000pub(crate) fn get_timezone_inner() -> Result { get_timezone().ok_or(crate::GetTimezoneError::OsError) } #[inline] fn get_timezone() -> Option { // The longest name in the IANA time zone database is 25 ASCII characters long. const MAX_LEN: usize = 32; let mut buf = [0; MAX_LEN]; // Get system time zone, and borrow its name. let tz = system_time_zone::SystemTimeZone::new()?; let name = tz.name()?; // If the name is encoded in UTF-8, copy it directly. let name = if let Some(name) = name.as_utf8() { name } else { // Otherwise convert the name to UTF-8. name.to_utf8(&mut buf)? }; if name.is_empty() || name.len() >= MAX_LEN { // The name should not be empty, or excessively long. None } else { Some(name.to_owned()) } } mod system_time_zone { //! create a safe wrapper around `CFTimeZoneRef` use core_foundation_sys::base::{CFRelease, CFTypeRef}; use core_foundation_sys::timezone::{CFTimeZoneCopySystem, CFTimeZoneGetName, CFTimeZoneRef}; pub(crate) struct SystemTimeZone(CFTimeZoneRef); impl Drop for SystemTimeZone { fn drop(&mut self) { // SAFETY: `SystemTimeZone` is only ever created with a valid `CFTimeZoneRef`. unsafe { CFRelease(self.0 as CFTypeRef) }; } } impl SystemTimeZone { pub(crate) fn new() -> Option { // SAFETY: No invariants to uphold. We'll release the pointer when we don't need it anymore. let v: CFTimeZoneRef = unsafe { CFTimeZoneCopySystem() }; if v.is_null() { None } else { Some(SystemTimeZone(v)) } } /// Get the time zone name as a [super::string_ref::StringRef]. /// /// The lifetime of the `StringRef` is bound to our lifetime. Mutable /// access is also prevented by taking a reference to `self`. pub(crate) fn name(&self) -> Option> { // SAFETY: `SystemTimeZone` is only ever created with a valid `CFTimeZoneRef`. let string = unsafe { CFTimeZoneGetName(self.0) }; if string.is_null() { None } else { // SAFETY: here we ensure that `string` is a valid pointer. Some(unsafe { super::string_ref::StringRef::new(string, self) }) } } } } mod string_ref { //! create safe wrapper around `CFStringRef` use std::convert::TryInto; use core_foundation_sys::base::{Boolean, CFRange}; use core_foundation_sys::string::{ kCFStringEncodingUTF8, CFStringGetBytes, CFStringGetCStringPtr, CFStringGetLength, CFStringRef, }; pub(crate) struct StringRef<'a, T> { string: CFStringRef, // We exclude mutable access to the parent by taking a reference to the // parent (rather than, for example, just using a marker to enforce the // parent's lifetime). _parent: &'a T, } impl<'a, T> StringRef<'a, T> { // SAFETY: `StringRef` must be valid pointer pub(crate) unsafe fn new(string: CFStringRef, _parent: &'a T) -> Self { Self { string, _parent } } pub(crate) fn as_utf8(&self) -> Option<&'a str> { // SAFETY: `StringRef` is only ever created with a valid `CFStringRef`. let v = unsafe { CFStringGetCStringPtr(self.string, kCFStringEncodingUTF8) }; if !v.is_null() { // SAFETY: `CFStringGetCStringPtr()` returns NUL-terminated strings. let v = unsafe { std::ffi::CStr::from_ptr(v) }; if let Ok(v) = v.to_str() { return Some(v); } } None } pub(crate) fn to_utf8<'b>(&self, buf: &'b mut [u8]) -> Option<&'b str> { // SAFETY: `StringRef` is only ever created with a valid `CFStringRef`. let length = unsafe { CFStringGetLength(self.string) }; let mut buf_bytes = 0; let range = CFRange { location: 0, length, }; let converted_bytes = unsafe { // SAFETY: `StringRef` is only ever created with a valid `CFStringRef`. CFStringGetBytes( self.string, range, kCFStringEncodingUTF8, b'\0', false as Boolean, buf.as_mut_ptr(), buf.len() as isize, &mut buf_bytes, ) }; if converted_bytes != length { return None; } let len = buf_bytes.try_into().ok()?; let s = buf.get(..len)?; std::str::from_utf8(s).ok() } } } iana-time-zone-0.1.53/src/tz_netbsd.rs000064400000000000000000000015571046102023000156700ustar 00000000000000use std::fs::read_link; pub(crate) fn get_timezone_inner() -> Result { // see https://www.cyberciti.biz/faq/openbsd-time-zone-howto/ // This is a backport of the Linux implementation. // NetBSDs is less than thorough how the softlink should be set up. const PREFIXES: &[&str] = &[ "/usr/share/zoneinfo/", // absolute path "../usr/share/zoneinfo/", // relative path ]; let mut s = read_link("/etc/localtime")? .into_os_string() .into_string() .map_err(|_| crate::GetTimezoneError::FailedParsingString)?; for &prefix in PREFIXES { if s.starts_with(prefix) { // Trim to the correct length without allocating. s.replace_range(..prefix.len(), ""); return Ok(s); } } Err(crate::GetTimezoneError::FailedParsingString) } iana-time-zone-0.1.53/src/tz_wasm32.rs000064400000000000000000000011321046102023000155120ustar 00000000000000use js_sys::{Array, Intl, Object, Reflect}; use wasm_bindgen::JsValue; pub(crate) fn get_timezone_inner() -> Result { let intl = Intl::DateTimeFormat::new(&Array::new(), &Object::new()).resolved_options(); Reflect::get(&intl, &JsValue::from_str("timeZone")) .ok() .and_then(|tz| tz.as_string()) .ok_or(crate::GetTimezoneError::OsError) } #[cfg(test)] mod tests { use wasm_bindgen_test::*; #[wasm_bindgen_test] fn pass() { let tz = super::get_timezone_inner().unwrap(); console_log!("tz={:?}", tz); } } iana-time-zone-0.1.53/src/tz_windows.rs000064400000000000000000000133721046102023000161010ustar 00000000000000use std::{io, mem, ptr, slice, sync}; use winapi::ctypes::wchar_t; use winapi::shared::winerror::{CO_E_NOTINITIALIZED, FAILED, HRESULT}; use winapi::um::combaseapi::CoIncrementMTAUsage; use winapi::um::unknwnbase::IUnknown; use winapi::winrt::activation::IActivationFactory; use winapi::winrt::hstring::{HSTRING, HSTRING_HEADER}; use winapi::winrt::inspectable::IInspectable; use winapi::winrt::roapi::RoGetActivationFactory; use winapi::winrt::winstring::{ WindowsCreateStringReference, WindowsDeleteString, WindowsGetStringRawBuffer, }; use winapi::Interface; use self::interfaces::ITimeZoneOnCalendar; macro_rules! wstring { ($($letters:tt)+) => { [ $($letters as wchar_t,)+ ] }; } const WINDOWS_GLOBALIZATION_CALENDAR: &[wchar_t] = &wstring!( 'W' 'i' 'n' 'd' 'o' 'w' 's' '.' 'G' 'l' 'o' 'b' 'a' 'l' 'i' 'z' 'a' 't' 'i' 'o' 'n' '.' 'C' 'a' 'l' 'e' 'n' 'd' 'a' 'r' 0 ); static INITIALIZED: sync::Once = sync::Once::new(); static mut FACTORY: Result, HRESULT> = Err(0); #[repr(transparent)] struct HString(HSTRING); #[repr(transparent)] struct Unknown(*mut T); impl std::convert::From for crate::GetTimezoneError { fn from(orig: HRESULT) -> Self { io::Error::from_raw_os_error(orig).into() } } pub(crate) fn get_timezone_inner() -> Result { unsafe { Ok(get_timezone()?) } } unsafe fn get_timezone() -> Result { // This function crates a Windows.Globalization.Calendar, gets its ITimeZoneOnCalendar, and // then the name of the timezone. // We memorize the calendar constructor instead of an instance, because the user could // change their timezone during the execution of the program. Caching the constructor makes // the stress-test example run about 3% faster. INITIALIZED.call_once(|| initialize_factory()); let factory = match FACTORY { Ok(ref factory) => factory, Err(err) => return Err(err), }; let mut calendar: Unknown = mem::zeroed(); let hr = (*factory.0).ActivateInstance(mem::transmute(&mut calendar)); if FAILED(hr) { return Err(hr); } let mut tz_on_caledar: Unknown = mem::zeroed(); let hr = (*calendar.0).QueryInterface( &ITimeZoneOnCalendar::uuidof(), mem::transmute(&mut tz_on_caledar), ); drop(calendar); if FAILED(hr) { return Err(hr); } let mut timezone: HString = mem::zeroed(); let hr = (*tz_on_caledar.0).GetTimeZone(mem::transmute(&mut timezone)); drop(tz_on_caledar); if FAILED(hr) { return Err(hr); } let mut len = 0; let buf = WindowsGetStringRawBuffer(timezone.0, &mut len); Ok(String::from_utf16_lossy(slice::from_raw_parts( &*buf, len as usize, ))) } unsafe fn initialize_factory() { // Some other liberary could have called CoIncrementMTAUsage() or CoInitializeEx(), so we only // call CoIncrementMTAUsage() if RoGetActivationFactory() tells us that multithreading was not // initialized, yet. let mut h_class_name: HString = mem::zeroed(); let mut string_header: HSTRING_HEADER = mem::zeroed(); let hr = WindowsCreateStringReference( WINDOWS_GLOBALIZATION_CALENDAR.as_ptr(), (WINDOWS_GLOBALIZATION_CALENDAR.len() - 1) as _, &mut string_header as *mut _, mem::transmute(&mut h_class_name), ); if FAILED(hr) { mem::swap(&mut FACTORY, &mut Err(hr)); return; } let mut factory: Unknown = mem::zeroed(); let hr = RoGetActivationFactory( h_class_name.0, &IActivationFactory::uuidof(), mem::transmute(&mut factory), ); if !FAILED(hr) { mem::swap(&mut FACTORY, &mut Ok(factory)); return; } else if hr != CO_E_NOTINITIALIZED { mem::swap(&mut FACTORY, &mut Err(hr)); return; } // No need to check the error. The only conceivable error code this function returns is // E_OUTOFMEMORY, and the program is about to get OOM killed anyway in this case. Windows-rs // does not check the result, either. let mut cookie = mem::zeroed(); let _ = CoIncrementMTAUsage(&mut cookie); let mut factory: Unknown = mem::zeroed(); let hr = RoGetActivationFactory( h_class_name.0, &IActivationFactory::uuidof(), mem::transmute(&mut factory), ); match !FAILED(hr) { true => mem::swap(&mut FACTORY, &mut Ok(factory)), false => mem::swap(&mut FACTORY, &mut Err(hr)), } } impl Drop for HString { fn drop(&mut self) { let string = mem::replace(&mut self.0, ptr::null_mut()); if !string.is_null() { unsafe { WindowsDeleteString(string) }; } } } impl Drop for Unknown { fn drop(&mut self) { let instance = mem::replace(&mut self.0, ptr::null_mut()); if !instance.is_null() { unsafe { (*(instance as *mut IUnknown)).Release() }; } } } #[allow(non_snake_case, non_camel_case_types)] mod interfaces { use winapi::shared::minwindef::DWORD; use winapi::shared::winerror::HRESULT; use winapi::winrt::hstring::HSTRING; use winapi::winrt::inspectable::{IInspectable, IInspectableVtbl}; use winapi::RIDL; RIDL! { #[uuid(0xbb3c25e5, 0x46cf, 0x4317, 0xa3, 0xf5, 0x02, 0x62, 0x1a, 0xd5, 0x44, 0x78)] interface ITimeZoneOnCalendar(ITimeZoneOnCalendar_Vtbl): IInspectable(IInspectableVtbl) { fn GetTimeZone(result: &mut HSTRING,) -> HRESULT, fn ChangeTimeZone(timezoneid: HSTRING,) -> HRESULT, fn TimeZoneAsFullString(result: &mut HSTRING,) -> HRESULT, fn TimeZoneAsString(ideallength: &DWORD, result: &mut HSTRING,) -> HRESULT, } } }