Skip to content

Commit

Permalink
Consolidate from_ffi and update_from_ffi logic
Browse files Browse the repository at this point in the history
  • Loading branch information
scouten-adobe committed Nov 5, 2022
1 parent 4490e89 commit 07c9c78
Showing 1 changed file with 3 additions and 33 deletions.
36 changes: 3 additions & 33 deletions src/xmp_date_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,39 +121,9 @@ impl XmpDateTime {
}

pub(crate) fn from_ffi(dt: &ffi::CXmpDateTime) -> Self {
Self {
date: if dt.has_date {
Some(XmpDate {
year: dt.year,
month: dt.month,
day: dt.day,
})
} else {
None
},
time: if dt.has_time {
Some(XmpTime {
hour: dt.hour,
minute: dt.minute,
second: dt.second,
nanosecond: dt.nanosecond,
time_zone: if dt.has_time_zone {
Some(XmpTimeZone {
hour: if dt.tz_sign < 0 {
-dt.tz_hour
} else {
dt.tz_hour
},
minute: dt.tz_minute,
})
} else {
None
},
})
} else {
None
},
}
let mut result = Self::default();
result.update_from_ffi(dt);
result
}

pub(crate) fn update_from_ffi(&mut self, dt: &ffi::CXmpDateTime) {
Expand Down

0 comments on commit 07c9c78

Please sign in to comment.