diff --git a/Cargo.lock b/Cargo.lock index fdb5a30352..89169c0efd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2187,6 +2187,7 @@ dependencies = [ "simplelog", "smallvec", "smol", + "time 0.3.2", "tiny-skia", "tree-sitter", "usvg", diff --git a/gpui/Cargo.toml b/gpui/Cargo.toml index b6b29c39e2..11a855cd40 100644 --- a/gpui/Cargo.toml +++ b/gpui/Cargo.toml @@ -27,6 +27,7 @@ serde = { version = "1.0.125", features = ["derive"] } serde_json = "1.0.64" smallvec = { version = "1.6", features = ["union"] } smol = "1.2" +time = { version = "0.3" } tiny-skia = "0.5" tree-sitter = "0.19" usvg = "0.14" diff --git a/gpui/src/platform.rs b/gpui/src/platform.rs index 21679ae877..b58ad381a2 100644 --- a/gpui/src/platform.rs +++ b/gpui/src/platform.rs @@ -26,6 +26,7 @@ use std::{ rc::Rc, sync::Arc, }; +use time::UtcOffset; pub trait Platform: Send + Sync { fn dispatcher(&self) -> Arc; @@ -49,6 +50,8 @@ pub trait Platform: Send + Sync { fn read_credentials(&self, url: &str) -> Option<(String, Vec)>; fn set_cursor_style(&self, style: CursorStyle); + + fn local_timezone(&self) -> UtcOffset; } pub(crate) trait ForegroundPlatform { diff --git a/gpui/src/platform/mac/platform.rs b/gpui/src/platform/mac/platform.rs index 861984a247..4d81fe964a 100644 --- a/gpui/src/platform/mac/platform.rs +++ b/gpui/src/platform/mac/platform.rs @@ -42,6 +42,7 @@ use std::{ slice, str, sync::Arc, }; +use time::UtcOffset; const MAC_PLATFORM_IVAR: &'static str = "platform"; static mut APP_CLASS: *const Class = ptr::null(); @@ -558,6 +559,14 @@ impl platform::Platform for MacPlatform { let _: () = msg_send![cursor, set]; } } + + fn local_timezone(&self) -> UtcOffset { + unsafe { + let local_timezone: id = msg_send![class!(NSTimeZone), localTimeZone]; + let seconds_from_gmt: NSInteger = msg_send![local_timezone, secondsFromGMT]; + UtcOffset::from_whole_seconds(seconds_from_gmt.try_into().unwrap()).unwrap() + } + } } unsafe fn get_foreground_platform(object: &mut Object) -> &MacForegroundPlatform { diff --git a/gpui/src/platform/test.rs b/gpui/src/platform/test.rs index 3295fb6382..004b1f94a9 100644 --- a/gpui/src/platform/test.rs +++ b/gpui/src/platform/test.rs @@ -9,6 +9,7 @@ use std::{ rc::Rc, sync::Arc, }; +use time::UtcOffset; pub struct Platform { dispatcher: Arc, @@ -136,6 +137,10 @@ impl super::Platform for Platform { fn set_cursor_style(&self, style: CursorStyle) { *self.cursor.lock() = style; } + + fn local_timezone(&self) -> UtcOffset { + UtcOffset::UTC + } } impl Window { diff --git a/zed/Cargo.toml b/zed/Cargo.toml index b77ed8caff..17314ebd65 100644 --- a/zed/Cargo.toml +++ b/zed/Cargo.toml @@ -49,7 +49,7 @@ smallvec = { version = "1.6", features = ["union"] } smol = "1.2.5" surf = "2.2" tempdir = { version = "0.3.7", optional = true } -time = { version = "0.3", features = ["local-offset"] } +time = { version = "0.3" } tiny_http = "0.8" toml = "0.5" tree-sitter = "0.19.5" diff --git a/zed/src/chat_panel.rs b/zed/src/chat_panel.rs index 6edac94b2e..6b52f7edfd 100644 --- a/zed/src/chat_panel.rs +++ b/zed/src/chat_panel.rs @@ -25,6 +25,7 @@ pub struct ChatPanel { input_editor: ViewHandle, channel_select: ViewHandle