use to_string to return the format distance string from FormatDistance

This commit is contained in:
Nate Butler
2023-12-19 11:57:57 -05:00
parent d8a8feb45c
commit a1085184a1
+10
View File
@@ -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