Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

use `to_string` to return the format distance string from FormatDistance

Nate Butlera1085184a143
diff --git a/crates/ui2/src/utils/format_distance.rs b/crates/ui2/src/utils/format_distance.rs
index 1586a6e155b..b0fce184ce6 100644
--- a/crates/ui2/src/utils/format_distance.rs
+++ b/crates/ui2/src/utils/format_distance.rs
@@ -42,6 +42,16 @@ impl FormatDistance {
Self::new(date, DateTimeType::Local(Local::now()))
}
+ pub fn to_string(self) -> String {
+ format_distance(
+ self.date,
+ self.base_date.to_naive(),
+ self.include_seconds,
+ self.add_suffix,
+ self.hide_prefix,
+ )
+ }
+
pub fn include_seconds(mut self, include_seconds: bool) -> Self {
self.include_seconds = include_seconds;
self