Struct xmp_toolkit::XmpDateTime
source · [−]Expand description
The XmpDateTime
struct allows easy conversion between ISO8601 format
(the “native” representation of dates and times in XMP) and other formats.
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.
XmpDateTime
values are occasionally used with only a date or only a time
component. These possibilities are expressed using Option
s.
Note that the DateTime
struct in the chrono
crate
is similar to this struct. We chose not to use that in the
Rust XMP Toolkit in order to provide a more precise mapping
to the API provided by the underlying C++ XMP Toolkit.
Fields
date: Option<XmpDate>
The date, if known.
time: Option<XmpTime>
The time, if known.
Implementations
sourceimpl XmpDateTime
impl XmpDateTime
Trait Implementations
sourceimpl Clone for XmpDateTime
impl Clone for XmpDateTime
sourcefn clone(&self) -> XmpDateTime
fn clone(&self) -> XmpDateTime
1.0.0 · sourceconst fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl Debug for XmpDateTime
impl Debug for XmpDateTime
sourceimpl Default for XmpDateTime
impl Default for XmpDateTime
sourcefn default() -> XmpDateTime
fn default() -> XmpDateTime
sourceimpl Display for XmpDateTime
impl Display for XmpDateTime
sourcefn fmt(&self, f: &mut Formatter<'_>) -> Result
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 yearMM
= 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 secondTZD
= 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.