Skip to content

Commit 949f3fa

Browse files
authored
Adjust compilation configuration of tzdb to target_family from target_os (#125)
This PR is meant to address issues with boa-dev/boa#4068, which breaks when compiling for WASM targets. The changes were not made to the tests as I don't believe those will affect compilation. As a side note, we should probably be testing `temporal_rs` on more targets in CI if possible, especially with adding a FFI on the horizon.
1 parent 232ae15 commit 949f3fa

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/tzdb.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
// offset diff = is_dst { dst_off - std_off } else { std_off - dst_off }, i.e. to_offset - from_offset
2929

3030
use std::path::Path;
31-
#[cfg(not(target_os = "windows"))]
31+
#[cfg(target_family = "unix")]
3232
use std::path::PathBuf;
3333

3434
use alloc::collections::BTreeMap;
@@ -53,7 +53,7 @@ use crate::{
5353
utils, TemporalError, TemporalResult,
5454
};
5555

56-
#[cfg(not(target_os = "windows"))]
56+
#[cfg(target_family = "unix")]
5757
const ZONEINFO_DIR: &str = "/usr/share/zoneinfo/";
5858

5959
/// `LocalTimeRecord` represents an local time offset record.
@@ -182,7 +182,7 @@ impl Tzif {
182182
Ok(Self::from(parse_result))
183183
}
184184

185-
#[cfg(not(target_os = "windows"))]
185+
#[cfg(target_family = "unix")]
186186
pub fn read_tzif(identifier: &str) -> TemporalResult<Self> {
187187
let mut path = PathBuf::from(ZONEINFO_DIR);
188188
path.push(identifier);
@@ -517,10 +517,10 @@ impl FsTzdbProvider {
517517
if let Some(tzif) = self.cache.borrow().get(identifier) {
518518
return Ok(tzif.clone());
519519
}
520-
#[cfg(any(target_os = "linux", target_os = "macos"))]
520+
#[cfg(target_family = "unix")]
521521
let (identifier, tzif) = { (identifier, Tzif::read_tzif(identifier)?) };
522522

523-
#[cfg(target_os = "windows")]
523+
#[cfg(any(target_family = "windows", target_family = "wasm"))]
524524
let (identifier, tzif) = {
525525
let Some((canonical_name, data)) = jiff_tzdb::get(identifier) else {
526526
return Err(

0 commit comments

Comments
 (0)