chore: Fix several style lints (#17488)

It's not comprehensive enough to start linting on `style` group, but
hey, it's a start.

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2024-09-06 11:58:39 +02:00 committed by GitHub
parent 93249fc82b
commit e6c1c51b37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
361 changed files with 3530 additions and 3587 deletions

View file

@ -42,16 +42,6 @@ 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
@ -68,6 +58,21 @@ impl FormatDistance {
}
}
impl std::fmt::Display for FormatDistance {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}",
format_distance(
self.date,
self.base_date.to_naive(),
self.include_seconds,
self.add_suffix,
self.hide_prefix,
)
)
}
}
/// Calculates the distance in seconds between two [`NaiveDateTime`] objects.
/// It returns a signed integer denoting the difference. If `date` is earlier than `base_date`, the returned value will be negative.
///
@ -118,12 +123,7 @@ fn distance_string(
}
.to_string()
} else if distance < 40 && include_seconds {
if hide_prefix {
"half a minute"
} else {
"half a minute"
}
.to_string()
"half a minute".to_string()
} else if distance < 60 && include_seconds {
if hide_prefix {
"a minute"