Skip to content
Open
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ exclude = [
[workspace.dependencies]
# Self
temporal_rs = { version = "0.1.2", path = ".", default-features = false }
timezone_provider = { version = "0.1.2", path = "./provider" }
timezone_provider = { version = "0.1.2", path = "./provider", default-features = false }
zoneinfo_rs = { version = "0.0.18", path = "./zoneinfo" }

# Dependencies
Expand Down
2 changes: 1 addition & 1 deletion provider/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ zerovec = { workspace = true, features = ["derive", "alloc"] }
tinystr = { workspace = true, features = ["zerovec"] }

# IANA dependency
zoneinfo_rs = { workspace = true, features = ["std"], optional = true }
zoneinfo_rs = { workspace = true, features = ["std", "unstable"], optional = true }

# tzif dependency
tzif = { workspace = true, optional = true }
Expand Down
2 changes: 1 addition & 1 deletion zoneinfo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ rust-version.workspace = true
authors.workspace = true
license.workspace = true
repository.workspace = true
readme.workspace = true
exclude.workspace = true
include = [
"src/**/*",
Expand All @@ -19,6 +18,7 @@ include = [

[features]
std = []
unstable = []

[dependencies]
hashbrown = "0.16.0"
Expand Down
3 changes: 2 additions & 1 deletion zoneinfo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ zoneinfo files.
```rust
use std::path::Path;
use zoneinfo_rs::{ZoneInfoData, ZoneInfoCompiler};
// Below assumes we are in the parent directory of `tzdata`
// Below assumes we are in the parent directory of `tzdata`.
let zoneinfo_filepath = Path::new("./tzdata/");
// Parse and then compile the files from the directory.
let parsed_data = ZoneInfoData::from_zoneinfo_directory(zoneinfo_filepath)?;
let _compiled_data = ZoneInfoCompiler::new(parsed_data).build();
```
Expand Down
19 changes: 11 additions & 8 deletions zoneinfo/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@

use alloc::collections::BTreeSet;
use alloc::string::String;

#[cfg(feature = "unstable")]
use crate::tzif::TzifBlockV2;
use crate::{
posix::PosixTimeZone,
types::{QualifiedTimeKind, Time},
zone::ZoneRecord,
ZoneInfoData,
};

use hashbrown::HashMap;

#[derive(Debug, Clone, PartialEq)]
Expand Down Expand Up @@ -108,6 +118,7 @@ pub struct CompiledTransitions {
//
// I think I would prefer all of that live in the `tzif` crate, but that will
// be a process to update. So implement it here, and then upstream it?
#[cfg(feature = "unstable")]
impl CompiledTransitions {
pub fn to_v2_data_block(&self) -> TzifBlockV2 {
TzifBlockV2::from_transition_data(self)
Expand All @@ -123,14 +134,6 @@ pub struct CompiledTransitionsMap {

// ==== ZoneInfoCompiler build / compile methods ====

use crate::{
posix::PosixTimeZone,
types::{QualifiedTimeKind, Time},
tzif::TzifBlockV2,
zone::ZoneRecord,
ZoneInfoData,
};

/// The compiler for turning `ZoneInfoData` into `CompiledTransitionsData`
pub struct ZoneInfoCompiler {
data: ZoneInfoData,
Expand Down
5 changes: 4 additions & 1 deletion zoneinfo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ pub mod parser;
pub mod posix;
pub mod rule;
pub mod types;
pub mod tzif;
pub mod zone;

#[cfg(feature = "unstable")]
pub mod tzif;

#[doc(inline)]
pub use compiler::ZoneInfoCompiler;

Expand All @@ -67,6 +69,7 @@ use rule::Rules;
use zone::ZoneRecord;

/// Well-known zone info file
#[doc(hidden)]
pub const ZONEINFO_FILES: &[&str] = &[
"africa",
"antarctica",
Expand Down
15 changes: 11 additions & 4 deletions zoneinfo/src/posix.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
//! POSIX time zone types and implementation
//!
//! For more information on POSIX time zones, see the [GNU docs][gnu-docs].
//!
//! [gnu-docs]: https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html

use crate::{
rule::{LastRules, Rule},
types::{DayOfMonth, Month, QualifiedTime, Sign, Time, WeekDay},
types::{
rule::{DayOfMonth, WeekDay},
Month, QualifiedTime, Sign, Time,
},
utils::month_to_day,
zone::ZoneEntry,
};
use alloc::string::String;
use core::fmt::Write;

/// The POSIX time zone designated by the [GNU documentation][gnu-docs]
///
/// [gnu-docs]: https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
/// A parsed POSIX time zone
#[derive(Debug, PartialEq)]
pub struct PosixTimeZone {
pub abbr: PosixAbbreviation,
Expand Down
7 changes: 5 additions & 2 deletions zoneinfo/src/rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ use alloc::{borrow::ToOwned, string::String, vec, vec::Vec};

use crate::{
parser::{next_split, ContextParse, LineParseContext, ZoneInfoParseError},
types::{DayOfMonth, Month, QualifiedTime, Time, ToYear},
types::{
rule::{DayOfMonth, ToYear},
Month, QualifiedTime, Time,
},
utils::{self, epoch_seconds_for_epoch_days},
};

Expand Down Expand Up @@ -301,7 +304,7 @@ impl Rule {
#[cfg(test)]
mod tests {
use super::*;
use crate::types::{Sign, WeekDay};
use crate::types::{rule::WeekDay, Sign};

const TEST_DATA: [&str; 22] = [
"Rule Algeria 1916 only - Jun 14 23:00s 1:00 S",
Expand Down
Loading
Loading