1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
// Copyright 2020 Adobe. All rights reserved.
// This file is licensed to you under the Apache License,
// Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
// or the MIT license (http://opensource.org/licenses/MIT),
// at your option.
// Unless required by applicable law or agreed to in writing,
// this software is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or
// implied. See the LICENSE-MIT and LICENSE-APACHE files for the
// specific language governing permissions and limitations under
// each license.
use crate::ffi;
/// The expanded type for a date and time.
///
/// Dates and time in the serialized XMP are ISO 8601 strings.
/// The `XmpDateTime` struct allows easy conversion with other formats.
pub struct XmpDateTime {
pub(crate) dt: *mut ffi::CXmpDateTime,
}
impl Drop for XmpDateTime {
fn drop(&mut self) {
unsafe {
ffi::CXmpDateTimeDrop(self.dt);
}
}
}
impl Default for XmpDateTime {
fn default() -> Self {
XmpDateTime::new()
}
}
impl XmpDateTime {
/// Creates a new date-time struct with zeros in all fields.
pub fn new() -> XmpDateTime {
XmpDateTime {
dt: unsafe { ffi::CXmpDateTimeNew() },
}
}
/// Creates a new date-time struct reflecting the current time.
pub fn current() -> XmpDateTime {
XmpDateTime {
dt: unsafe { ffi::CXmpDateTimeCurrent() },
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn new_empty() {
let mut _dt = XmpDateTime::new();
}
#[test]
fn current() {
let mut _dt = XmpDateTime::current();
}
}