pub struct XmpDateTime {
    pub date: Option<XmpDate>,
    pub time: Option<XmpTime>,
}
Expand description

Represents the concept of date and time as expressed in XMP.

XMP understands a close variant of the ISO8601 format, where date, time, and time zone are all optional fields. These possibilities are expressed using Options.

All of the fields are signed 32 bit integers, even though most could be 8 bit. (The same is true in the underlying C++ XMP Toolkit.) This avoids overflow when doing carries for arithmetic or normalization.

The DateTime struct in the chrono crate is similar to this struct, but does not provide a way to express the optionality of date, time, and time zone in a single struct. For that reason, we did not use it in this crate.

Enable crate feature chrono to enable conversions between this struct and chrono::DateTime<FixedOffset>.

Fields§

§date: Option<XmpDate>

The date, if known.

§time: Option<XmpTime>

The time, if known.

Implementations§

source§

impl XmpDateTime

source

pub fn current() -> XmpResult<Self>

Creates a new date-time struct reflecting the current time.

source

pub fn set_local_time_zone(&mut self) -> XmpResult<()>

Sets the time zone to the local time zone.

Can only be used when there is a time with no existing time zone (i.e. self.time.time_zone.is_none()). It is an error to call this function with an existing time zone.

In that case, the time zone value is replaced with the local time zone. The other date/time fields are not adjusted in any way.

source

pub fn convert_to_local_time(&mut self) -> XmpResult<()>

Translate the value to the local time zone.

If the time zone is not the local zone, the time is adjusted and the time zone set to be local. The value is not modified if the time zone is already the local zone or if the value has no time zone.

source

pub fn convert_to_utc(&mut self) -> XmpResult<()>

Translates the value to UTC (Coordinated Universal Time).

If the time zone is not UTC, the time is adjusted and the time zone set to be UTC. The value is not modified if the time zone is already UTC or if the value has no time zone.

Trait Implementations§

source§

impl Clone for XmpDateTime

source§

fn clone(&self) -> XmpDateTime

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for XmpDateTime

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for XmpDateTime

source§

fn default() -> XmpDateTime

Returns the “default value” for a type. Read more
source§

impl Display for XmpDateTime

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats a date according to the ISO 8601 profile in https://www.w3.org/TR/NOTE-datetime.

The format will be one of the following:

  • YYYY
  • YYYY-MM-DD
  • YYYY-MM-DDThh:mmTZD
  • YYYY-MM-DDThh:mm:ssTZD
  • YYYY-MM-DDThh:mm:ss.sTZD

Where:

  • YYYY = four-digit year
  • MM = two-digit month (01=January)
  • DD = two-digit day of month (01 through 31)
  • hh = two digits of hour (00 through 23)
  • mm = two digits of minute (00 through 59)
  • ss = two digits of second (00 through 59)
  • s = one or more digits representing a decimal fraction of a second
  • TZD = time zone designator (Z or +hh:mm or -hh:mm)

XMP allows time-only values (date = None). In this case, the date portion of the output will be 0000-01-01.

NOTE: ISO 8601 does not allow years less than 1000 or greater than 9999. XmpDateTime allows any year, even negative ones. The W3C profile also requires a time zone designator if a time is present; since XmpDateTime has an explicit notion of zone-less time, the TZD will not appear in that case.

source§

impl From<&DateTime<FixedOffset>> for XmpDateTime

source§

fn from(dt: &DateTime<FixedOffset>) -> Self

Converts to this type from the input type.
source§

impl From<DateTime<FixedOffset>> for XmpDateTime

source§

fn from(dt: DateTime<FixedOffset>) -> Self

Converts to this type from the input type.
source§

impl PartialEq for XmpDateTime

source§

fn eq(&self, other: &XmpDateTime) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl TryFrom<&XmpDateTime> for DateTime<FixedOffset>

§

type Error = DateTimeConvertError

The type returned in the event of a conversion error.
source§

fn try_from(dt: &XmpDateTime) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<XmpDateTime> for DateTime<FixedOffset>

§

type Error = DateTimeConvertError

The type returned in the event of a conversion error.
source§

fn try_from(dt: XmpDateTime) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Eq for XmpDateTime

source§

impl StructuralPartialEq for XmpDateTime

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.