Skip to main content

Time

Struct Time 

Source
pub struct Time {
    pub value: String,
    pub format: TimeFormat,
    pub scale: TimeScale,
    pub location: Location,
    pub civil: Option<Civil>,
}
Expand description

A time as it appears in a file.

Fields§

§value: String

The value exactly as written.

§format: TimeFormat

The effective format, with format and base_format collapsed.

§scale: TimeScale

The time scale.

§location: Location

The observer’s location, for location-sensitive scales.

§civil: Option<Civil>

The derived calendar breakdown, once computed.

Implementations§

Source§

impl Time

Source

pub fn new( value: impl Into<String>, format: TimeFormat, scale: TimeScale, ) -> Self

A time with the given value and format.

Source

pub fn parse(doc: &Document, id: NodeId) -> Result<Self>

Read a time/time value from the tree.

The schema allows two shapes: the whole tagged value as a string, or a mapping with the string under value and optional format, base_format, scale and location.

The wire format says how to read the value; base_format records the object’s real format and overrides only what it reports afterwards. An astropy plot_date is stored as an ISO string with base_format: plot_date, so collapsing the two before parsing would try to read a date as a matplotlib ordinal.

The calendar breakdown is computed where the value allows it; a value that will not parse is not an error, since the value, format and scale round-trip regardless and the breakdown is a convenience.

Source

pub fn compute_civil(&mut self) -> Result<Civil>

Compute the calendar breakdown from the value, format and scale.

Approximate for anything off the UTC scale; see the module comment.

Source

pub fn wire_formats(&self) -> (TimeFormat, Option<TimeFormat>)

The pair of values to write: the wire format, and base_format when the effective format may not appear in format.

Trait Implementations§

Source§

impl Clone for Time

Source§

fn clone(&self) -> Time

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Time

Source§

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

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

impl PartialEq for Time

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Time

Auto Trait Implementations§

§

impl Freeze for Time

§

impl RefUnwindSafe for Time

§

impl Send for Time

§

impl Sync for Time

§

impl Unpin for Time

§

impl UnsafeUnpin for Time

§

impl UnwindSafe for Time

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.