Refactor timestamp formatting in Git UI components to use chrono for local time calculations (#41005)
- Updated `blame_ui.rs`, `branch_picker.rs`, `commit_tooltip.rs`, and `commit_view.rs` to replace the previous timestamp formatting with `chrono` for better accuracy in local time representation. - Introduced `chrono::Local::now().offset().local_minus_utc()` to obtain the local offset for timestamp formatting. Closes #40878 Release Notes: - Improved timestamp handling in various Git UI components for enhanced user experience.
This commit is contained in:
@@ -415,12 +415,14 @@ fn format_commit(commit: &CommitDetails, is_stash: bool) -> String {
|
||||
commit.author_name, commit.author_email
|
||||
)
|
||||
.unwrap();
|
||||
let local_offset = time::UtcOffset::current_local_offset().unwrap_or(time::UtcOffset::UTC);
|
||||
writeln!(
|
||||
&mut result,
|
||||
"Date: {}",
|
||||
time_format::format_local_timestamp(
|
||||
time_format::format_localized_timestamp(
|
||||
time::OffsetDateTime::from_unix_timestamp(commit.commit_timestamp).unwrap(),
|
||||
time::OffsetDateTime::now_utc(),
|
||||
local_offset,
|
||||
time_format::TimestampFormat::MediumAbsolute,
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user