summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2017-11-19 15:39:29 +0100
committerGitHub <noreply@github.com>2017-11-19 15:39:29 +0100
commit902f04bd7c975b7d97849327b464e0e5db1f9ec5 (patch)
tree6a196716ea2a76b8102e80de6b0eb12a5de38d78
parent4f29717c49f891a60d41280c72a86966e2b5cd73 (diff)
parent59c69e7c094355e2ec7c9372e18e6da4cdbfc44f (diff)
Merge pull request #10 from matthiasbeyer/impl-unimpl
Implement not-yet implemented match arms
-rw-r--r--src/parser/timetype.rs53
1 files changed, 33 insertions, 20 deletions
diff --git a/src/parser/timetype.rs b/src/parser/timetype.rs
index 935f18a..62e321b 100644
--- a/src/parser/timetype.rs
+++ b/src/parser/timetype.rs
@@ -157,37 +157,50 @@ impl Into<timetype::TimeType> for ExactDate {
ExactDate::Yesterday => timetype::TimeType::today() - timetype::TimeType::days(1),
ExactDate::Tomorrow => timetype::TimeType::today() + timetype::TimeType::days(1),
ExactDate::Iso8601Date(date) => {
- let (year, month, day) = match date {
+ match date {
::iso8601::Date::YMD { year, month, day } => {
- (year, month, day)
+ let ndt = NaiveDate::from_ymd(year, month, day).and_hms(0, 0, 0);
+ timetype::TimeType::moment(ndt)
},
- ::iso8601::Date::Week { /* year, ww, d */ .. } => {
- unimplemented!()
+ ::iso8601::Date::Week { year, ww, d } => {
+ let ndt = NaiveDate::from_ymd(year, 1, 1).and_hms(0, 0, 0);
+ timetype::TimeType::moment(ndt)
+ + timetype::TimeType::weeks(ww as i64)
+ + timetype::TimeType::days(d as i64)
},
- ::iso8601::Date::Ordinal { /* year, ddd */ .. } => {
- unimplemented!()
+ ::iso8601::Date::Ordinal { year, ddd } => {
+ let ndt = NaiveDate::from_ymd(year, 1, 1).and_hms(0, 0, 0);
+ timetype::TimeType::moment(ndt)
+ + timetype::TimeType::days(ddd as i64)
},
- };
-
- let ndt = NaiveDate::from_ymd(year, month, day).and_hms(0, 0, 0);
- timetype::TimeType::moment(ndt)
+ }
},
ExactDate::Iso8601DateTime(::iso8601::DateTime { date, time }) => {
let (hour, minute, second) = (time.hour, time.minute, time.second);
- let (year, month, day) = match date {
+
+ match date {
::iso8601::Date::YMD { year, month, day } => {
- (year, month, day)
+ let ndt = NaiveDate::from_ymd(year, month, day).and_hms(hour, minute, second);
+ timetype::TimeType::moment(ndt)
},
- ::iso8601::Date::Week { /* year, ww, d */ .. } => {
- unimplemented!()
+ ::iso8601::Date::Week { year, ww, d } => {
+ let ndt = NaiveDate::from_ymd(year, 1, 1).and_hms(0, 0, 0);
+ timetype::TimeType::moment(ndt)
+ + timetype::TimeType::weeks(ww as i64)
+ + timetype::TimeType::days(d as i64)
+ + timetype::TimeType::hours(hour as i64)
+ + timetype::TimeType::minutes(minute as i64)
+ + timetype::TimeType::seconds(second as i64)
},
- ::iso8601::Date::Ordinal { /* year, ddd */ .. } => {
- unimplemented!()
+ ::iso8601::Date::Ordinal { year, ddd } => {
+ let ndt = NaiveDate::from_ymd(year, 1, 1).and_hms(0, 0, 0);
+ timetype::TimeType::moment(ndt)
+ + timetype::TimeType::days(ddd as i64)
+ + timetype::TimeType::hours(hour as i64)
+ + timetype::TimeType::minutes(minute as i64)
+ + timetype::TimeType::seconds(second as i64)
},
- };
-
- let ndt = NaiveDate::from_ymd(year, month, day).and_hms(hour, minute, second);
- timetype::TimeType::moment(ndt)
+ }
},
}
}