-
-
Notifications
You must be signed in to change notification settings - Fork 408
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial work on temporal ISO8601 parsing and grammar
- Loading branch information
Showing
19 changed files
with
1,327 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//! Temporal Annotation Nodes. | ||
/// A list of indidividual Annotation nodes. | ||
#[derive(Debug, Clone, Copy)] | ||
#[deny(dead_code)] | ||
pub struct Annotations; | ||
//{ | ||
// list: Box<[Annotation]>, | ||
//} | ||
|
||
/// An individual Annotation Information Node | ||
#[derive(Debug, Clone, Copy)] | ||
pub struct Annotation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
//! AST nodes for Temporal's implementation of ISO8601 grammar. | ||
use rustc_hash::FxHashMap; | ||
|
||
pub mod annotation; | ||
|
||
/// TBD... | ||
#[derive(Default, Debug)] | ||
pub struct AnnotatedDateTime { | ||
/// Parsed Date Record | ||
pub date_time: DateTimeRecord, | ||
/// Parsed `TimeZoneAnnotation` | ||
pub tz_annotation: Option<TimeZoneAnnotation>, | ||
/// Parsed Annotations | ||
pub annotations: Option<FxHashMap<String, (bool, String)>>, | ||
} | ||
|
||
#[derive(Default, Debug, Clone,Copy)] | ||
/// The record of a parsed date. | ||
pub struct DateRecord { | ||
/// Date Year | ||
pub year: i32, | ||
/// Date Month | ||
pub month: i32, | ||
/// Date Day | ||
pub day: i32, | ||
} | ||
|
||
/// Parsed Time info | ||
#[derive(Debug, Clone, Copy)] | ||
#[allow(dead_code)] | ||
pub struct TimeSpec { | ||
/// An hour | ||
pub hour: i8, | ||
/// A minute value | ||
pub minute: i8, | ||
/// A floating point second value. | ||
pub second: f64, | ||
} | ||
|
||
/// TimeZone UTC Offset info. | ||
#[derive(Debug, Clone, Copy)] | ||
pub struct DateTimeUtcOffset; | ||
|
||
#[derive(Debug, Default, Clone, Copy)] | ||
/// Boop | ||
pub struct DateTimeRecord { | ||
/// Date | ||
pub date: DateRecord, | ||
/// Time | ||
pub time: Option<TimeSpec>, | ||
/// Tz Offset | ||
pub offset: Option<UtcOffset>, | ||
} | ||
|
||
/// A TimeZoneAnnotation. | ||
#[derive(Debug, Clone)] | ||
#[allow(dead_code)] | ||
pub struct TimeZoneAnnotation { | ||
/// Critical Flag for the annotation. | ||
pub critical: bool, | ||
/// TimeZone Data | ||
pub tz: TzIdentifier, | ||
} | ||
|
||
/// A valid `TimeZoneIdentifier` that is defined by | ||
/// the specification as either a UTC Offset to minute | ||
/// precision or a `TimeZoneIANAName` | ||
#[derive(Debug, Clone)] | ||
pub enum TzIdentifier { | ||
/// A valid UTC `TimeZoneIdentifier` value | ||
UtcOffset(UtcOffset), | ||
/// A valid IANA name `TimeZoneIdentifier` value | ||
TzIANAName(String), | ||
} | ||
|
||
// NOTE: is it worth consolidating MinutePrecision vs. Offset | ||
/// A UTC Offset that maintains only minute precision. | ||
#[derive(Debug, Clone, Copy)] | ||
#[allow(dead_code)] | ||
pub struct UtcOffsetMinutePrecision { | ||
sign: i8, | ||
hour: i8, | ||
minute: i8, | ||
} | ||
|
||
/// A full precision `UtcOffset` | ||
#[derive(Debug, Clone, Copy)] | ||
#[allow(dead_code)] | ||
pub struct UtcOffset { | ||
/// The UTC flag | ||
pub utc: bool, | ||
/// The `+`/`-` sign of this `UtcOffset` | ||
pub sign: i8, | ||
/// The hour value of the `UtcOffset` | ||
pub hour: i8, | ||
/// The minute value of the `UtcOffset`. | ||
pub minute: i8, | ||
/// A float representing the second value of the `UtcOffset`. | ||
pub second: f64, | ||
} | ||
|
||
/// A KeyValueAnnotation Parse Node. | ||
#[derive(Debug, Clone)] | ||
#[allow(dead_code)] | ||
pub struct KeyValueAnnotation { | ||
/// An `Annotation`'s Key. | ||
pub key: String, | ||
/// An `Annotation`'s value. | ||
pub value: String, | ||
/// Whether the annotation was flagged as critical. | ||
pub critical: bool, | ||
} |
Oops, something went wrong.