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: StringThe value exactly as written.
format: TimeFormatThe effective format, with format and base_format collapsed.
scale: TimeScaleThe time scale.
location: LocationThe observer’s location, for location-sensitive scales.
civil: Option<Civil>The derived calendar breakdown, once computed.
Implementations§
Source§impl Time
impl Time
Sourcepub fn new(
value: impl Into<String>,
format: TimeFormat,
scale: TimeScale,
) -> Self
pub fn new( value: impl Into<String>, format: TimeFormat, scale: TimeScale, ) -> Self
A time with the given value and format.
Sourcepub fn parse(doc: &Document, id: NodeId) -> Result<Self>
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.
Sourcepub fn compute_civil(&mut self) -> Result<Civil>
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.
Sourcepub fn wire_formats(&self) -> (TimeFormat, Option<TimeFormat>)
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.