From 07c9c781dc141ff08448aaac86d99d8517f9e4b3 Mon Sep 17 00:00:00 2001 From: Eric Scouten Date: Sat, 5 Nov 2022 15:18:41 -0700 Subject: [PATCH] Consolidate from_ffi and update_from_ffi logic --- src/xmp_date_time.rs | 36 +++--------------------------------- 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/src/xmp_date_time.rs b/src/xmp_date_time.rs index 13a2558..257df23 100644 --- a/src/xmp_date_time.rs +++ b/src/xmp_date_time.rs @@ -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) {