Move function closer to its only uses

This commit is contained in:
Joscha 2023-08-17 00:40:51 +02:00
parent ca6a6be638
commit 0a9559f82a
2 changed files with 11 additions and 10 deletions

View file

@ -1,15 +1,10 @@
use std::time::Duration;
use gix::{actor::IdentityRef, date::Time};
use time::{macros::format_description, OffsetDateTime, UtcOffset};
use gix::actor::IdentityRef;
use time::{macros::format_description, OffsetDateTime};
use crate::somehow;
pub fn time_to_offset_datetime(time: Time) -> somehow::Result<OffsetDateTime> {
Ok(OffsetDateTime::from_unix_timestamp(time.seconds)?
.to_offset(UtcOffset::from_whole_seconds(time.offset)?))
}
pub fn format_duration(duration: time::Duration) -> String {
let seconds = duration.unsigned_abs().as_secs(); // To nearest second
let formatted = humantime::format_duration(Duration::from_secs(seconds));