1use time::{OffsetDateTime, UtcOffset};
4
5use crate::Error;
6
7pub fn convert_git2_time(time: git2::Time) -> Result<OffsetDateTime, Error> {
9 let time_secs_unix = time.seconds();
10 let mut dt = OffsetDateTime::from_unix_timestamp(time_secs_unix)
11 .map_err(|err| Error::msg(err.to_string().as_str()))?;
12
13 let time_tz_mins = time.offset_minutes();
14 let offset = UtcOffset::from_whole_seconds(60 * time_tz_mins)
15 .map_err(|err| Error::msg(err.to_string().as_str()))?;
16
17 dt = dt.to_offset(offset);
18 Ok(dt)
19}