pub struct ParsingComponents { /* private fields */ }Expand description
upstream ParsingComponents.
Rust’s Clone copies everything, tags included. Upstream’s clone() doesn’t copy tags: port
an upstream .clone() as ParsingComponents::js_clone (see PORTING.md).
Implementations§
Source§impl ParsingComponents
impl ParsingComponents
Sourcepub fn from_parts(
reference: ReferenceWithTimezone,
known: ComponentMap,
implied: ComponentMap,
tags: Vec<String>,
) -> ParsingComponents
pub fn from_parts( reference: ReferenceWithTimezone, known: ComponentMap, implied: ComponentMap, tags: Vec<String>, ) -> ParsingComponents
Components rebuilt from their parts (the harness feeds chrono-node’s results to one refiner,
chrono-rs-json --trace with isolate).
Sourcepub fn new(
reference: ReferenceWithTimezone,
known: &[(Component, i64)],
) -> ParsingComponents
pub fn new( reference: ReferenceWithTimezone, known: &[(Component, i64)], ) -> ParsingComponents
new ParsingComponents(reference, knownComponents).
Sourcepub fn create_relative_from_reference(
reference: ReferenceWithTimezone,
duration: &mut Duration,
) -> ParsingComponents
pub fn create_relative_from_reference( reference: ReferenceWithTimezone, duration: &mut Duration, ) -> ParsingComponents
ParsingComponents.createRelativeFromReference(reference, duration).
Like upstream, duration is mutated by add_duration (short keys renamed, fractions cascaded).
pub fn reference(&self) -> ReferenceWithTimezone
Sourcepub fn get(&self, c: Component) -> Option<i64>
pub fn get(&self, c: Component) -> Option<i64>
get(component): known, else implied, else None (JS null).
Sourcepub fn get_or_zero(&self, c: Component) -> i64
pub fn get_or_zero(&self, c: Component) -> i64
get(c) where upstream relies on JS turning null into 0 in arithmetic.
pub fn is_certain(&self, c: Component) -> bool
pub fn get_certain_components(&self) -> Vec<Component>
pub fn known_values(&self) -> &ComponentMap
pub fn implied_values(&self) -> &ComponentMap
Sourcepub fn imply(&mut self, c: Component, v: i64) -> &mut Self
pub fn imply(&mut self, c: Component, v: i64) -> &mut Self
imply(component, value): ignored if the component is already known.
Sourcepub fn add_duration_as_implied(&mut self, duration: &mut Duration) -> &mut Self
pub fn add_duration_as_implied(&mut self, duration: &mut Duration) -> &mut Self
addDurationAsImplied(duration). Like upstream, duration is mutated by add_duration.
pub fn delete(&mut self, components: &[Component])
pub fn is_only_date(&self) -> bool
pub fn is_only_time(&self) -> bool
pub fn is_only_weekday_component(&self) -> bool
pub fn is_date_with_unknown_year(&self) -> bool
Sourcepub fn is_valid_date(&self) -> bool
pub fn is_valid_date(&self) -> bool
isValidDate().
Sourcepub fn date_without_timezone_adjustment(&self) -> JsDate
pub fn date_without_timezone_adjustment(&self) -> JsDate
The components read as system-local time (UTC here), with setFullYear fixing 0–99 years.
pub fn add_tag(&mut self, tag: &str) -> &mut Self
Sourcepub fn js_clone(&self) -> ParsingComponents
pub fn js_clone(&self) -> ParsingComponents
Tags in insertion order (a JS Set).
upstream clone(): the reference and the known and implied values, without the tags.
Use this wherever upstream calls .clone() on components.