pub struct IonDateTime { /* private fields */ }Expand description
Higher-level wrapper over DateTime preserving ION_TIMESTAMP properties
that DateTime does not preserve on its own.
Specifically, this adds the precision of the timestamp and its associated kind of offset.
§Usage
Generally, users will create their own DateTime<FixedOffset>
and construct an IonDateTime indicating the precision as follows:
// construct a DateTime with milliseconds of fractional seconds
use ion_c_sys::timestamp::Mantissa::Digits;
let dt = DateTime::parse_from_rfc3339("2020-02-27T04:15:00.123Z").unwrap();
// move that into an IonDateTime with the explicit milliseconds of precision
let ion_dt = IonDateTime::try_new(dt, Fractional(Digits(3)), KnownOffset)?;Implementations§
Source§impl IonDateTime
impl IonDateTime
Sourcepub fn try_new(
date_time: DateTime<FixedOffset>,
precision: TSPrecision,
offset_kind: TSOffsetKind,
) -> IonCResult<Self>
pub fn try_new( date_time: DateTime<FixedOffset>, precision: TSPrecision, offset_kind: TSOffsetKind, ) -> IonCResult<Self>
Constructs a new IonDateTime from its constituent components.
Note that the Fractional precision must match the nanoseconds field of this
will fail. Also note that the TSOffsetKind must be Unknown for precision less than
a Minute and must correspond to UTC+00:00 in the DateTime.
Sourcepub fn as_datetime(&self) -> &DateTime<FixedOffset>
pub fn as_datetime(&self) -> &DateTime<FixedOffset>
Returns a reference to the underlying DateTime.
Sourcepub fn precision(&self) -> &TSPrecision
pub fn precision(&self) -> &TSPrecision
Returns the precision of this IonDateTime.
Sourcepub fn offset_kind(&self) -> TSOffsetKind
pub fn offset_kind(&self) -> TSOffsetKind
Returns the offset of this IonDateTime.
Sourcepub fn into_datetime(self) -> DateTime<FixedOffset>
pub fn into_datetime(self) -> DateTime<FixedOffset>
Consumes the underlying components of this IonDateTime into a DateTime.
Trait Implementations§
Source§impl Clone for IonDateTime
impl Clone for IonDateTime
Source§fn clone(&self) -> IonDateTime
fn clone(&self) -> IonDateTime
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more