feat: add dependency
This commit is contained in:
9
javascript-engine/external/iana-time-zone/.clang-format
vendored
Normal file
9
javascript-engine/external/iana-time-zone/.clang-format
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
BasedOnStyle: Google
|
||||
IndentWidth: 4
|
||||
ColumnLimit: 100
|
||||
---
|
||||
Language: Cpp
|
||||
SortIncludes: false
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
||||
12
javascript-engine/external/iana-time-zone/.github/dependabot.yml
vendored
Normal file
12
javascript-engine/external/iana-time-zone/.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
version: 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
|
||||
383
javascript-engine/external/iana-time-zone/.github/workflows/rust.yml
vendored
Normal file
383
javascript-engine/external/iana-time-zone/.github/workflows/rust.yml
vendored
Normal file
@@ -0,0 +1,383 @@
|
||||
name: 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.48"
|
||||
- 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.48'
|
||||
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.48"
|
||||
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"
|
||||
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
|
||||
override: true
|
||||
target: ${{ matrix.target }}
|
||||
- name: Update lockfile
|
||||
run: cargo generate-lockfile ${{ matrix.versions }}
|
||||
env:
|
||||
RUSTC_BOOTSTRAP: 1
|
||||
|
||||
# The command is derived from `cargo-quickinstall`'s description:
|
||||
# https://github.com/cargo-bins/cargo-quickinstall/blob/49f09436/README.md#use-in-ci-systems
|
||||
#
|
||||
# I.e. Download the file into STDOUT, follow redirects, don't give status reports, except
|
||||
# if there are HTTP errors, and in case of HTTP errors don't pipe out anything at all.
|
||||
# Extract everything into Cargo's `cargo install` destination, which is in your $PATH already.
|
||||
#
|
||||
# Updated pre-compiled binaries can be found in <https://github.com/cargo-bins/cargo-quickinstall/releases>
|
||||
# by searching for their project name.
|
||||
- name: Install "cross"
|
||||
run: curl --location --silent --show-error --fail https://github.com/cargo-bins/cargo-quickinstall/releases/download/cross-0.2.4-x86_64-unknown-linux-gnu/cross-0.2.4-x86_64-unknown-linux-gnu.tar.gz | tar -xzvvf - -C $HOME/.cargo/bin
|
||||
|
||||
- run: cross build --target ${{ matrix.target }} --examples
|
||||
|
||||
build-ios-cross:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
toolchain:
|
||||
- "1.48"
|
||||
- stable
|
||||
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.48"
|
||||
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
|
||||
- name: Install "cross"
|
||||
run: curl --location --silent --show-error --fail https://github.com/cargo-bins/cargo-quickinstall/releases/download/cross-0.2.4-x86_64-apple-darwin/cross-0.2.4-x86_64-apple-darwin.tar.gz | tar -xzvvf - -C $HOME/.cargo/bin
|
||||
- run: cross build --target ${{ matrix.target }} --examples
|
||||
|
||||
check:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
toolchain:
|
||||
- "1.48"
|
||||
- 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..
|
||||
2
javascript-engine/external/iana-time-zone/.gitignore
vendored
Normal file
2
javascript-engine/external/iana-time-zone/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
target
|
||||
Cargo.lock
|
||||
297
javascript-engine/external/iana-time-zone/CHANGELOG.md
vendored
Normal file
297
javascript-engine/external/iana-time-zone/CHANGELOG.md
vendored
Normal file
@@ -0,0 +1,297 @@
|
||||
# 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.54] - 2022-12-21
|
||||
### Changed
|
||||
- replace `winapi` dependency with `windows-sys` ([#91](https://github.com/strawlab/iana-time-zone/pull/91))
|
||||
- bump msrv to 1.48 ([#91](https://github.com/strawlab/iana-time-zone/pull/91))
|
||||
|
||||
## [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.54]: https://github.com/strawlab/iana-time-zone/releases/tag/v0.1.54
|
||||
[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
|
||||
43
javascript-engine/external/iana-time-zone/Cargo.toml
vendored
Normal file
43
javascript-engine/external/iana-time-zone/Cargo.toml
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
[package]
|
||||
name = "iana-time-zone"
|
||||
description = "get the IANA time zone for the current system"
|
||||
# Origin version is: 0.1.54, modify the version to 0.1.53
|
||||
version = "0.1.53"
|
||||
authors = [
|
||||
"Andrew Straw <strawman@astraw.com>",
|
||||
"René Kijewski <rene.kijewski@fu-berlin.de>",
|
||||
"Ryan Lopopolo <rjl@hyperbo.la>",
|
||||
]
|
||||
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]
|
||||
windows-sys = { version = "0.42.0", features = ["Win32_Globalization", "Win32_System_Com", "Win32_System_WinRT"] }
|
||||
|
||||
[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 = ["."]
|
||||
201
javascript-engine/external/iana-time-zone/LICENSE-APACHE
vendored
Normal file
201
javascript-engine/external/iana-time-zone/LICENSE-APACHE
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
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.
|
||||
25
javascript-engine/external/iana-time-zone/LICENSE-MIT
vendored
Normal file
25
javascript-engine/external/iana-time-zone/LICENSE-MIT
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
Copyright (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.
|
||||
47
javascript-engine/external/iana-time-zone/README.md
vendored
Normal file
47
javascript-engine/external/iana-time-zone/README.md
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
# iana-time-zone - get the IANA time zone for the current system
|
||||
|
||||
[](https://crates.io/crates/iana-time-zone)
|
||||
[](https://docs.rs/iana-time-zone/)
|
||||
[](https://crates.io/crates/iana-time-zone)
|
||||
[](https://github.com/strawlab/iana-time-zone/actions?query=branch%3Amain)
|
||||
|
||||
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.48
|
||||
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
|
||||
<http://www.apache.org/licenses/LICENSE-2.0>)
|
||||
* MIT license ([LICENSE-MIT](LICENSE-MIT) or
|
||||
<http://opensource.org/licenses/MIT>)
|
||||
|
||||
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.
|
||||
6
javascript-engine/external/iana-time-zone/examples/get_timezone.rs
vendored
Normal file
6
javascript-engine/external/iana-time-zone/examples/get_timezone.rs
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
use iana_time_zone::{get_timezone, GetTimezoneError};
|
||||
|
||||
fn main() -> Result<(), GetTimezoneError> {
|
||||
println!("{}", get_timezone()?);
|
||||
Ok(())
|
||||
}
|
||||
25
javascript-engine/external/iana-time-zone/examples/stress-test.rs
vendored
Normal file
25
javascript-engine/external/iana-time-zone/examples/stress-test.rs
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
use 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);
|
||||
}
|
||||
17
javascript-engine/external/iana-time-zone/haiku/Cargo.toml
vendored
Normal file
17
javascript-engine/external/iana-time-zone/haiku/Cargo.toml
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
[package]
|
||||
name = "iana-time-zone-haiku"
|
||||
description = "iana-time-zone support crate for Haiku OS"
|
||||
version = "0.1.1"
|
||||
authors = ["René Kijewski <crates.io@k6i.de>"]
|
||||
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"
|
||||
|
||||
[dependencies]
|
||||
cxx = "1.0.34"
|
||||
|
||||
[build-dependencies]
|
||||
cxx-build = "1.0.34"
|
||||
1
javascript-engine/external/iana-time-zone/haiku/LICENSE-APACHE
vendored
Symbolic link
1
javascript-engine/external/iana-time-zone/haiku/LICENSE-APACHE
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../LICENSE-APACHE
|
||||
1
javascript-engine/external/iana-time-zone/haiku/LICENSE-MIT
vendored
Symbolic link
1
javascript-engine/external/iana-time-zone/haiku/LICENSE-MIT
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../LICENSE-MIT
|
||||
8
javascript-engine/external/iana-time-zone/haiku/README.md
vendored
Normal file
8
javascript-engine/external/iana-time-zone/haiku/README.md
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# iana-time-zone-haiku
|
||||
|
||||
[](https://crates.io/crates/iana-time-zone-haiku)
|
||||
[](https://docs.rs/iana-time-zone/)
|
||||
[](https://crates.io/crates/iana-time-zone-haiku)
|
||||
[](https://github.com/strawlab/iana-time-zone/actions?query=branch%3Amain)
|
||||
|
||||
[iana-time-zone](https://github.com/strawlab/iana-time-zone) support crate for Haiku OS.
|
||||
20
javascript-engine/external/iana-time-zone/haiku/build.rs
vendored
Normal file
20
javascript-engine/external/iana-time-zone/haiku/build.rs
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
use std::env;
|
||||
|
||||
fn main() {
|
||||
cxx_build::bridge("src/lib.rs")
|
||||
.file("src/implementation.cc")
|
||||
.flag_if_supported("-std=c++11")
|
||||
.compile("tz_haiku");
|
||||
|
||||
println!("cargo:rerun-if-changed=src/lib.rs");
|
||||
println!("cargo:rerun-if-changed=src/implementation.cc");
|
||||
println!("cargo:rerun-if-changed=src/interface.h");
|
||||
|
||||
let target = env::var_os("TARGET").expect("cargo should set TARGET env var");
|
||||
let target = target
|
||||
.to_str()
|
||||
.expect("TARGET env var should be valid UTF-8");
|
||||
if target.contains("haiku") {
|
||||
println!("cargo:rustc-link-lib=be");
|
||||
}
|
||||
}
|
||||
66
javascript-engine/external/iana-time-zone/haiku/src/implementation.cc
vendored
Normal file
66
javascript-engine/external/iana-time-zone/haiku/src/implementation.cc
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
#include "iana-time-zone-haiku/src/interface.h"
|
||||
#include "iana-time-zone-haiku/src/lib.rs.h"
|
||||
|
||||
#ifdef __HAIKU__
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include <Errors.h>
|
||||
#include <LocaleRoster.h>
|
||||
#include <String.h>
|
||||
#include <TimeZone.h>
|
||||
|
||||
namespace iana_time_zone_haiku {
|
||||
size_t get_tz(rust::Slice<uint8_t> buf) {
|
||||
try {
|
||||
static_assert(sizeof(char) == sizeof(uint8_t), "Illegal char size");
|
||||
|
||||
if (buf.empty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// `BLocaleRoster::Default()` returns a reference to a statically allocated object.
|
||||
// https://github.com/haiku/haiku/blob/8f16317/src/kits/locale/LocaleRoster.cpp#L143-L147
|
||||
BLocaleRoster *locale_roster(BLocaleRoster::Default());
|
||||
if (!locale_roster) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
BTimeZone tz(NULL, NULL);
|
||||
if (locale_roster->GetDefaultTimeZone(&tz) != B_OK) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
BString bname(tz.ID());
|
||||
int32_t ilength(bname.Length());
|
||||
if (ilength <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t length(ilength);
|
||||
if (length > buf.size()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// BString::String() returns a borrowed string.
|
||||
// https://www.haiku-os.org/docs/api/classBString.html#ae4fe78b06c8e3310093b80305e14ba87
|
||||
const char *sname(bname.String());
|
||||
if (!sname) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::memcpy(buf.data(), sname, length);
|
||||
return length;
|
||||
} catch (...) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} // namespace iana_time_zone_haiku
|
||||
|
||||
#else
|
||||
|
||||
namespace iana_time_zone_haiku {
|
||||
size_t get_tz(rust::Slice<uint8_t>) { return 0; }
|
||||
} // namespace iana_time_zone_haiku
|
||||
|
||||
#endif
|
||||
9
javascript-engine/external/iana-time-zone/haiku/src/interface.h
vendored
Normal file
9
javascript-engine/external/iana-time-zone/haiku/src/interface.h
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "rust/cxx.h"
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
namespace iana_time_zone_haiku {
|
||||
size_t get_tz(rust::Slice<uint8_t> buf);
|
||||
}
|
||||
68
javascript-engine/external/iana-time-zone/haiku/src/lib.rs
vendored
Normal file
68
javascript-engine/external/iana-time-zone/haiku/src/lib.rs
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
#![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(unsafe_op_in_unsafe_fn)]
|
||||
#![warn(unused_qualifications)]
|
||||
#![warn(variant_size_differences)]
|
||||
|
||||
//! # iana-time-zone-haiku
|
||||
//!
|
||||
//! [](https://crates.io/crates/iana-time-zone-haiku)
|
||||
//! [](https://docs.rs/iana-time-zone/)
|
||||
//! [](https://crates.io/crates/iana-time-zone-haiku)
|
||||
//! [](https://github.com/strawlab/iana-time-zone/actions?query=branch%3Amain)
|
||||
//!
|
||||
//! [iana-time-zone](https://github.com/strawlab/iana-time-zone) support crate for Haiku OS.
|
||||
|
||||
#[cxx::bridge(namespace = "iana_time_zone_haiku")]
|
||||
mod ffi {
|
||||
// SAFETY: in here "unsafe" is simply part of the syntax
|
||||
unsafe extern "C++" {
|
||||
include!("iana-time-zone-haiku/src/interface.h");
|
||||
|
||||
fn get_tz(buf: &mut [u8]) -> usize;
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the current IANA time zone as a string.
|
||||
///
|
||||
/// On Haiku platforms this function will return [`Some`] with the timezone string
|
||||
/// or [`None`] if an error occurs. On all other platforms, [`None`] is returned.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// let timezone = iana_time_zone_haiku::get_timezone();
|
||||
/// ```
|
||||
pub fn get_timezone() -> Option<String> {
|
||||
// The longest name in the IANA time zone database is 25 ASCII characters long.
|
||||
let mut buf = [0u8; 32];
|
||||
let len = ffi::get_tz(&mut buf);
|
||||
// The name should not be empty, or excessively long.
|
||||
match buf.get(..len)? {
|
||||
b"" => None,
|
||||
s => Some(std::str::from_utf8(s).ok()?.to_owned()),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
#[cfg(not(target_os = "haiku"))]
|
||||
fn test_fallback_on_non_haiku_platforms() {
|
||||
assert!(super::get_timezone().is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "haiku")]
|
||||
fn test_retrieve_time_zone_on_haiku_platforms() {
|
||||
let timezone = super::get_timezone().unwrap();
|
||||
assert!(!timezone.is_empty());
|
||||
}
|
||||
}
|
||||
49
javascript-engine/external/iana-time-zone/src/ffi_utils.rs
vendored
Normal file
49
javascript-engine/external/iana-time-zone/src/ffi_utils.rs
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
//! 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();
|
||||
}
|
||||
}
|
||||
113
javascript-engine/external/iana-time-zone/src/lib.rs
vendored
Normal file
113
javascript-engine/external/iana-time-zone/src/lib.rs
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
#![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<std::io::Error> 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<String, GetTimezoneError> {
|
||||
platform::get_timezone_inner()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn get_current() {
|
||||
println!("current: {}", get_timezone().unwrap());
|
||||
}
|
||||
}
|
||||
9
javascript-engine/external/iana-time-zone/src/platform.rs
vendored
Normal file
9
javascript-engine/external/iana-time-zone/src/platform.rs
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
pub fn get_timezone_inner() -> std::result::Result<String, crate::GetTimezoneError> {
|
||||
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.",
|
||||
);
|
||||
27
javascript-engine/external/iana-time-zone/src/tz_android.rs
vendored
Normal file
27
javascript-engine/external/iana-time-zone/src/tz_android.rs
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
use std::sync::Once;
|
||||
|
||||
use android_system_properties::AndroidSystemProperties;
|
||||
|
||||
use crate::ffi_utils::android_timezone_property_name;
|
||||
|
||||
pub(crate) fn get_timezone_inner() -> Result<String, crate::GetTimezoneError> {
|
||||
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<AndroidSystemProperties> = 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() }
|
||||
}
|
||||
7
javascript-engine/external/iana-time-zone/src/tz_freebsd.rs
vendored
Normal file
7
javascript-engine/external/iana-time-zone/src/tz_freebsd.rs
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
pub(crate) fn get_timezone_inner() -> Result<String, crate::GetTimezoneError> {
|
||||
// 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)
|
||||
}
|
||||
3
javascript-engine/external/iana-time-zone/src/tz_haiku.rs
vendored
Normal file
3
javascript-engine/external/iana-time-zone/src/tz_haiku.rs
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
pub(crate) fn get_timezone_inner() -> Result<String, crate::GetTimezoneError> {
|
||||
iana_time_zone_haiku::get_timezone().ok_or(crate::GetTimezoneError::OsError)
|
||||
}
|
||||
22
javascript-engine/external/iana-time-zone/src/tz_illumos.rs
vendored
Normal file
22
javascript-engine/external/iana-time-zone/src/tz_illumos.rs
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
use std::fs::OpenOptions;
|
||||
use std::io::{BufRead, BufReader};
|
||||
|
||||
pub(crate) fn get_timezone_inner() -> Result<String, crate::GetTimezoneError> {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
45
javascript-engine/external/iana-time-zone/src/tz_linux.rs
vendored
Normal file
45
javascript-engine/external/iana-time-zone/src/tz_linux.rs
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
use std::fs::{read_link, read_to_string};
|
||||
|
||||
pub(crate) fn get_timezone_inner() -> Result<String, crate::GetTimezoneError> {
|
||||
etc_localtime().or_else(|_| etc_timezone())
|
||||
}
|
||||
|
||||
fn etc_timezone() -> Result<String, crate::GetTimezoneError> {
|
||||
// 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<String, crate::GetTimezoneError> {
|
||||
// Per <https://www.man7.org/linux/man-pages/man5/localtime.5.html>:
|
||||
// “ 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.
|
||||
// <https://github.com/systemd/systemd/blob/9102c625a673a3246d7e73d8737f3494446bad4e/src/basic/time-util.c#L1493>
|
||||
|
||||
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)
|
||||
}
|
||||
144
javascript-engine/external/iana-time-zone/src/tz_macos.rs
vendored
Normal file
144
javascript-engine/external/iana-time-zone/src/tz_macos.rs
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
pub(crate) fn get_timezone_inner() -> Result<String, crate::GetTimezoneError> {
|
||||
get_timezone().ok_or(crate::GetTimezoneError::OsError)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn get_timezone() -> Option<String> {
|
||||
// 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<Self> {
|
||||
// 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<super::string_ref::StringRef<'_, Self>> {
|
||||
// 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()
|
||||
}
|
||||
}
|
||||
}
|
||||
25
javascript-engine/external/iana-time-zone/src/tz_netbsd.rs
vendored
Normal file
25
javascript-engine/external/iana-time-zone/src/tz_netbsd.rs
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
use std::fs::read_link;
|
||||
|
||||
pub(crate) fn get_timezone_inner() -> Result<String, crate::GetTimezoneError> {
|
||||
// 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)
|
||||
}
|
||||
21
javascript-engine/external/iana-time-zone/src/tz_wasm32.rs
vendored
Normal file
21
javascript-engine/external/iana-time-zone/src/tz_wasm32.rs
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
use js_sys::{Array, Intl, Object, Reflect};
|
||||
use wasm_bindgen::JsValue;
|
||||
|
||||
pub(crate) fn get_timezone_inner() -> Result<String, crate::GetTimezoneError> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
312
javascript-engine/external/iana-time-zone/src/tz_windows.rs
vendored
Normal file
312
javascript-engine/external/iana-time-zone/src/tz_windows.rs
vendored
Normal file
@@ -0,0 +1,312 @@
|
||||
use std::mem::zeroed;
|
||||
|
||||
use windows_sys::core::{GUID, HRESULT};
|
||||
use windows_sys::Win32::System::Com::CoIncrementMTAUsage;
|
||||
use windows_sys::Win32::System::WinRT::HSTRING_HEADER;
|
||||
|
||||
use self::hstring::HString;
|
||||
use self::instance::Instance;
|
||||
use self::tz_on_calendar::TzOnCalendar;
|
||||
|
||||
macro_rules! wstring {
|
||||
($($letters:tt)+) => {
|
||||
[ $($letters as _,)+ ]
|
||||
};
|
||||
}
|
||||
|
||||
const WINDOWS_GLOBALIZATION_CALENDAR: &[u16] = &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
|
||||
);
|
||||
|
||||
const TIMEZONE_ON_CALENDAR_GUID: GUID = GUID {
|
||||
data1: 0xbb3c25e5,
|
||||
data2: 0x46cf,
|
||||
data3: 0x4317,
|
||||
data4: [0xa3, 0xf5, 0x02, 0x62, 0x1a, 0xd5, 0x44, 0x78],
|
||||
};
|
||||
|
||||
const CO_E_NOTINITIALIZED: HRESULT = -2147221008;
|
||||
|
||||
impl From<HRESULT> for crate::GetTimezoneError {
|
||||
fn from(orig: HRESULT) -> Self {
|
||||
std::io::Error::from_raw_os_error(orig).into()
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn get_timezone_inner() -> Result<String, crate::GetTimezoneError> {
|
||||
// Get HSTRING for "Windows.Globalization.Calendar".
|
||||
// SAFETY: An `HSTRING_HEADER` actually does not need initialization when used with
|
||||
// `WindowsCreateStringReference()`, but zeroing it is as good a initial value as any.
|
||||
let mut string_header: HSTRING_HEADER = unsafe { zeroed() };
|
||||
let class_name = HString::create(WINDOWS_GLOBALIZATION_CALENDAR, &mut string_header)?;
|
||||
|
||||
// Create new "Windows.Globalization.Calendar" instance.
|
||||
let calendar = Instance::activate(&class_name).or_else(|result| {
|
||||
// Some other library could have called CoIncrementMTAUsage() or CoInitializeEx(), so we
|
||||
// only call CoIncrementMTAUsage() if RoActivateInstance() tells us that multithreading
|
||||
// was not initialized, yet.
|
||||
|
||||
// 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.
|
||||
|
||||
if result != CO_E_NOTINITIALIZED {
|
||||
return Err(result);
|
||||
}
|
||||
let mut cookie = 0;
|
||||
// SAFETY: "Don't call CoIncrementMTAUsage during process shutdown or inside dllmain."
|
||||
// Using the function is `fn main()` is totally fine. If you go really low level
|
||||
// and implement an "fn wWinMain()" somehow, then all bets are off anyway.
|
||||
let _ = unsafe { CoIncrementMTAUsage(&mut cookie) };
|
||||
|
||||
Instance::activate(&class_name)
|
||||
})?;
|
||||
|
||||
// Query ITimeZoneOnCalendar of the calendar instance.
|
||||
let tz = TzOnCalendar::query(&calendar)?;
|
||||
|
||||
// Get the name of the time zone.
|
||||
let name = HString::from_tz_on_calendar(&tz)?;
|
||||
|
||||
// Convert to Rust String
|
||||
Ok(name.to_string())
|
||||
}
|
||||
|
||||
mod hstring {
|
||||
use std::ptr::null_mut;
|
||||
|
||||
use windows_sys::core::{HRESULT, HSTRING};
|
||||
use windows_sys::Win32::System::WinRT::WindowsDeleteString;
|
||||
use windows_sys::Win32::System::WinRT::{
|
||||
WindowsCreateStringReference, WindowsGetStringRawBuffer, HSTRING_HEADER,
|
||||
};
|
||||
|
||||
use super::tz_on_calendar::TzOnCalendar;
|
||||
|
||||
pub struct HString<'a> {
|
||||
string: HSTRING,
|
||||
_header: Option<&'a mut HSTRING_HEADER>,
|
||||
}
|
||||
|
||||
impl<'a> HString<'a> {
|
||||
// `source` must be null-terminated. Windows tests if the the terminator is missing and
|
||||
// returns an error if it is absent.
|
||||
pub fn create(source: &'a [u16], header: &'a mut HSTRING_HEADER) -> Result<Self, HRESULT> {
|
||||
let mut string = null_mut();
|
||||
// SAFETY: `source` is a valid reference. If its contents are not a valid wide string,
|
||||
// then the call will return an error code. We keep a reference to the `source`
|
||||
// and `header`, so they stay valid until the `HSTRING` is released.
|
||||
let result = unsafe {
|
||||
WindowsCreateStringReference(
|
||||
source.as_ptr(),
|
||||
(source.len().saturating_sub(1)) as u32,
|
||||
header,
|
||||
&mut string,
|
||||
)
|
||||
};
|
||||
if result < 0 || string.is_null() {
|
||||
Err(result)
|
||||
} else {
|
||||
Ok(Self {
|
||||
string,
|
||||
_header: Some(header),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_tz_on_calendar(instance: &'a TzOnCalendar) -> Result<Self, HRESULT> {
|
||||
let mut string = null_mut();
|
||||
// SAFETY: A `TzOnCalendar` is only ever created with a valid instance.
|
||||
let result = unsafe {
|
||||
let instance = instance.as_ptr();
|
||||
((**instance).GetTimeZone)(instance, &mut string)
|
||||
};
|
||||
if result < 0 || string.is_null() {
|
||||
Err(result)
|
||||
} else {
|
||||
Ok(Self {
|
||||
string,
|
||||
_header: None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// SAFETY: You are not allowed to release the returned pointer.
|
||||
pub unsafe fn as_ptr(&self) -> HSTRING {
|
||||
self.string
|
||||
}
|
||||
}
|
||||
|
||||
impl ToString for HString<'_> {
|
||||
fn to_string(&self) -> String {
|
||||
let mut len = 0;
|
||||
// SAFETY: An `HString` is only ever created with a valid `HSTRING`.
|
||||
// It keeps a reference to `HSTRING_HEADER` if needed.
|
||||
let buf = unsafe { WindowsGetStringRawBuffer(self.string, &mut len) };
|
||||
if len == 0 || buf.is_null() {
|
||||
return String::new();
|
||||
}
|
||||
|
||||
// SAFETY: `WindowsGetStringRawBuffer` returns a valid pointer to a wide string.
|
||||
let slice = unsafe { std::slice::from_raw_parts(buf, len as usize) };
|
||||
String::from_utf16_lossy(slice)
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for HString<'_> {
|
||||
fn drop(&mut self) {
|
||||
// SAFETY: An `HString` is only ever created with a valid `HSTRING`.
|
||||
unsafe { WindowsDeleteString(self.string) };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod instance {
|
||||
use std::ptr::null_mut;
|
||||
|
||||
use windows_sys::core::HRESULT;
|
||||
use windows_sys::Win32::System::WinRT::RoActivateInstance;
|
||||
|
||||
use super::hstring::HString;
|
||||
use super::interfaces::IUnknown;
|
||||
|
||||
pub struct Instance(IUnknown);
|
||||
|
||||
impl Instance {
|
||||
pub fn activate(class_id: &HString<'_>) -> Result<Self, HRESULT> {
|
||||
let mut instance = null_mut();
|
||||
// SAFETY: An `HString` is only ever crated with a valid `HSTRING`.
|
||||
let result = unsafe { RoActivateInstance(class_id.as_ptr(), &mut instance) };
|
||||
if result < 0 || instance.is_null() {
|
||||
Err(result)
|
||||
} else {
|
||||
Ok(Self(instance.cast()))
|
||||
}
|
||||
}
|
||||
|
||||
/// SAFETY: You are not allowed to release the returned pointer.
|
||||
pub unsafe fn as_ptr(&self) -> IUnknown {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Instance {
|
||||
fn drop(&mut self) {
|
||||
// SAFETY: An `Instance` is only ever created with a valid `IUnknown`.
|
||||
unsafe { ((**self.0).Release)(self.0) };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod tz_on_calendar {
|
||||
use std::ptr::null_mut;
|
||||
|
||||
use windows_sys::core::HRESULT;
|
||||
|
||||
use super::instance::Instance;
|
||||
use super::interfaces::{ITimeZoneOnCalendar, IUnknown};
|
||||
use super::TIMEZONE_ON_CALENDAR_GUID;
|
||||
|
||||
pub struct TzOnCalendar(ITimeZoneOnCalendar);
|
||||
|
||||
impl TzOnCalendar {
|
||||
pub fn query(source: &Instance) -> Result<Self, HRESULT> {
|
||||
let mut tz = null_mut();
|
||||
// SAFETY: An `Instance` is only ever created with a valid `IUnknown`.
|
||||
let result = unsafe {
|
||||
let source = source.as_ptr();
|
||||
((**source).QueryInterface)(source, &TIMEZONE_ON_CALENDAR_GUID, &mut tz)
|
||||
};
|
||||
if result < 0 || tz.is_null() {
|
||||
Err(result)
|
||||
} else {
|
||||
Ok(Self(tz.cast()))
|
||||
}
|
||||
}
|
||||
|
||||
/// SAFETY: You are not allowed to release the returned pointer.
|
||||
pub unsafe fn as_ptr(&self) -> ITimeZoneOnCalendar {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for TzOnCalendar {
|
||||
fn drop(&mut self) {
|
||||
let v: IUnknown = self.0.cast();
|
||||
// SAFETY: `TzOnCalendar` is only ever created with a valid `ITimeZoneOnCalendar`.
|
||||
unsafe { ((**v).Release)(v) };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
#[allow(non_camel_case_types)]
|
||||
mod interfaces {
|
||||
use std::ops::Deref;
|
||||
|
||||
use windows_sys::core::{GUID, HRESULT, HSTRING};
|
||||
|
||||
pub type IUnknown = *mut *const IUnknown_Vtbl;
|
||||
pub type IInspectable = *mut *const IInspectable_Vtbl;
|
||||
pub type ITimeZoneOnCalendar = *mut *const ITimeZoneOnCalendar_Vtbl;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct IUnknown_Vtbl {
|
||||
pub QueryInterface: unsafe extern "system" fn(
|
||||
this: IUnknown,
|
||||
iid: &GUID,
|
||||
interface: &mut IUnknown,
|
||||
) -> HRESULT,
|
||||
pub AddRef: unsafe extern "system" fn(this: IUnknown) -> u32,
|
||||
pub Release: unsafe extern "system" fn(this: IUnknown) -> u32,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct IInspectable_Vtbl {
|
||||
pub base: IUnknown_Vtbl,
|
||||
pub GetIids: unsafe extern "system" fn(
|
||||
this: IInspectable,
|
||||
count: &mut u32,
|
||||
values: &mut &mut GUID,
|
||||
) -> HRESULT,
|
||||
pub GetRuntimeClassName:
|
||||
unsafe extern "system" fn(this: IInspectable, value: &mut HSTRING) -> HRESULT,
|
||||
pub GetTrustLevel:
|
||||
unsafe extern "system" fn(this: IInspectable, value: &mut i32) -> HRESULT,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct ITimeZoneOnCalendar_Vtbl {
|
||||
pub base: IInspectable_Vtbl,
|
||||
pub GetTimeZone:
|
||||
unsafe extern "system" fn(this: ITimeZoneOnCalendar, result: &mut HSTRING) -> HRESULT,
|
||||
pub ChangeTimeZone:
|
||||
unsafe extern "system" fn(this: ITimeZoneOnCalendar, timezoneid: HSTRING) -> HRESULT,
|
||||
pub TimeZoneAsFullString:
|
||||
unsafe extern "system" fn(this: ITimeZoneOnCalendar, result: *mut HSTRING) -> HRESULT,
|
||||
pub TimeZoneAsString: unsafe extern "system" fn(
|
||||
this: ITimeZoneOnCalendar,
|
||||
ideallength: i32,
|
||||
result: &mut HSTRING,
|
||||
) -> HRESULT,
|
||||
}
|
||||
|
||||
impl Deref for IInspectable_Vtbl {
|
||||
type Target = IUnknown_Vtbl;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.base
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for ITimeZoneOnCalendar_Vtbl {
|
||||
type Target = IInspectable_Vtbl;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.base
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user