Skip to content

Commit d4fe100

Browse files
committed
Add timezone host functions.
1 parent 8efcb98 commit d4fe100

File tree

10 files changed

+261
-45
lines changed

10 files changed

+261
-45
lines changed

Cargo.lock

Lines changed: 170 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ authors = ["The Wasmtime Project Developers"]
125125
edition = "2021"
126126
rust-version = "1.71.0"
127127

128+
[patch.crates-io]
129+
cap-std = { path = "../cap-std/cap-std" }
130+
cap-fs-ext = { path = "../cap-std/cap-fs-ext" }
131+
cap-time-ext = { path = "../cap-std/cap-time-ext" }
132+
cap-net-ext = { path = "../cap-std/cap-net-ext" }
133+
128134
[workspace.dependencies]
129135
wasmtime-wmemcheck = { path = "crates/wmemcheck", version = "=13.0.0" }
130136
wasmtime = { path = "crates/wasmtime", version = "13.0.0", default-features = false }
@@ -254,6 +260,8 @@ futures = { version = "0.3.27", default-features = false }
254260
indexmap = "2.0.0"
255261
pretty_env_logger = "0.5.0"
256262
syn = "2.0.25"
263+
chrono = "0.4.26"
264+
chrono-tz = "0.8.3"
257265

258266
[features]
259267
default = [

crates/wasi/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ bitflags = { workspace = true, optional = true }
3838
async-trait = { workspace = true, optional = true }
3939
system-interface = { workspace = true, optional = true}
4040
futures = { workspace = true, optional = true }
41+
chrono = { workspace = true, optional = true }
42+
chrono-tz = { workspace = true, optional = true }
4143

4244
[dev-dependencies]
4345
tokio = { workspace = true, features = ["time", "sync", "io-std", "io-util", "rt", "rt-multi-thread", "net", "macros"] }
@@ -77,6 +79,8 @@ preview2 = [
7779
'dep:rustix',
7880
'dep:tokio',
7981
'dep:futures',
82+
'dep:chrono',
83+
'dep:chrono-tz',
8084
]
8185
preview1-on-preview2 = [
8286
"preview2",

crates/wasi/src/preview2/clocks.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
pub mod host;
2+
use crate::preview2::bindings::clocks::timezone::TimezoneDisplay;
23
use cap_std::time::Duration;
34

45
pub trait HostWallClock: Send + Sync {
@@ -10,3 +11,8 @@ pub trait HostMonotonicClock: Send + Sync {
1011
fn resolution(&self) -> u64;
1112
fn now(&self) -> u64;
1213
}
14+
15+
pub trait HostTimezone: Send + Sync {
16+
fn display(&self, datetime: Duration) -> TimezoneDisplay;
17+
fn utc_offset(&self, datetime: Duration) -> i32;
18+
}

0 commit comments

Comments
 (0)