linux: Implement local time zone support (#14610)

I decided to remove the GPUI APIs since `chrono` already provides this
functionality, and is already been used for this purpose in other parts
of the code (e.g.
[here](80402a6840/crates/zed/src/main.rs (L756))
or
[here](80402a6840/crates/ui/src/utils/format_distance.rs (L258)))

These usages end up calling the `time_format` crate, which takes in a
`UtcOffset`. It's probably cleaner to rewrite the crate to take in
`chrono` types, but that would require rewriting most of the code there.

Release Notes:

- linux: Use local time zone in chat and Git blame
This commit is contained in:
apricotbucket28 2024-07-18 08:42:18 -03:00 committed by GitHub
parent 22a2cc6950
commit 013c9f0420
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 26 additions and 72 deletions

View file

@ -16,7 +16,6 @@ use futures::channel::oneshot::{self, Receiver};
use itertools::Itertools;
use parking_lot::RwLock;
use smallvec::SmallVec;
use time::UtcOffset;
use windows::{
core::*,
Win32::{
@ -35,7 +34,6 @@ use windows::{
Ole::*,
SystemInformation::*,
Threading::*,
Time::*,
},
UI::{Input::KeyboardAndMouse::*, Shell::*, WindowsAndMessaging::*},
},
@ -482,25 +480,6 @@ impl Platform for WindowsPlatform {
Ok(std::env::current_exe()?)
}
fn local_timezone(&self) -> UtcOffset {
let mut info = unsafe { std::mem::zeroed() };
let ret = unsafe { GetTimeZoneInformation(&mut info) };
if ret == TIME_ZONE_ID_INVALID {
log::error!(
"Unable to get local timezone: {}",
std::io::Error::last_os_error()
);
return UtcOffset::UTC;
}
// Windows treat offset as:
// UTC = localtime + offset
// so we add a minus here
let hours = -info.Bias / 60;
let minutes = -info.Bias % 60;
UtcOffset::from_hms(hours as _, minutes as _, 0).unwrap()
}
// todo(windows)
fn path_for_auxiliary_executable(&self, name: &str) -> Result<PathBuf> {
Err(anyhow!("not yet implemented"))