Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
36 changes: 36 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,42 @@ jobs:
- name: Test all features
run: cargo test-all-features

zoneinfo:
name: Zoneinfo (IANA database)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
key: zoneinfo

# zic compiles the IANA sources into the TZif files used as ground truth.
- name: Install zic
run: |
sudo apt-get update
sudo apt-get install -y tzdata
echo /usr/sbin >> "$GITHUB_PATH"

# Fail here rather than inside the task if the package ever stops shipping it.
- name: Verify zic
run: zic --version

# Only nushell: Rust comes from rust-toolchain above so that rust-cache
# keeps working, per the mise-action README.
- uses: jdx/mise-action@v4
with:
install_args: "aqua:nushell/nushell"

# Downloads the pinned tzdata, verifies its checksum, compiles it with
# zic, regenerates the ground truth, and runs the zoneinfo tests.
- name: Test zoneinfo against the full IANA database
env:
# The task needs only nushell and cargo. Without this, `mise run`
# builds the dev-only cargo tools from mise.toml, costing minutes.
MISE_TASK_RUN_AUTO_INSTALL: "false"
run: mise run zoneinfo:test

ffi:
name: Test FFI (${{ matrix.rust.name }}, ${{ matrix.os }})
strategy:
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
debug/
target/
tzdata/
.tzdata/

# Include the data debug view
!/provider/src/data/debug
!/crates/provider/src/data/debug

# These are backup files generated by rustfmt
**/*.rs.bk
Expand All @@ -21,3 +22,6 @@ tzdata/
# Ignore clangd files
.cache
compile_commands.json

# Generated zoneinfo test data — produced by `mise run zoneinfo:test`
crates/zoneinfo/tests/data/*.json
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions crates/provider/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@ impl DstTransitionInfoForYear {
self.dst_start_seconds..self.dst_end_seconds
}
}

/// The offset in effect immediately after the transition at `seconds`.
pub(crate) fn offset_after(&self, seconds: i64) -> UtcOffsetSeconds {
if seconds == self.dst_start_seconds {
self.dst_offset
} else {
self.std_offset
}
}
}

#[cfg(feature = "tzif")]
Expand Down
4 changes: 2 additions & 2 deletions crates/provider/src/data/compiled_zoneinfo_provider.rs.data

Large diffs are not rendered by default.

Loading
Loading