aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuben Pollan2018-08-27 19:24:47 +0200
committerRuben Pollan2018-08-27 19:24:47 +0200
commit9a60ffb29c95485d11e60a0c77481e41715e8485 (patch)
tree2d98aa7d9961bd32bc8bd7cee33539a02225bc06
parent8acae5ce7497255eae1d16e6355b6da605bc2707 (diff)
Recognize absolute times
Diffstat (limited to '')
-rw-r--r--src/event.rs21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/event.rs b/src/event.rs
index 066b691..3594a11 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -82,14 +82,23 @@ impl Date {
}
pub fn parse(date: &String, time_zone: &String) -> Result<Self, EventError> {
- let tz: Tz = time_zone.parse().unwrap_or(UTC);
+ let absolute_time = date.chars().rev().next().unwrap() == 'Z';
+ let tz: Tz = if absolute_time {
+ UTC
+ } else {
+ // FIXME: this should not be UTC but local timezone
+ time_zone.parse().unwrap_or(UTC)
+ };
+
let date = match date.find("T") {
Some(_) => {
- let time = tz.datetime_from_str(&date, "%Y%m%dT%H%M%S").unwrap_or(
- UTC.timestamp(
- 0,
- 0,
- ),
+ let date_pattern = if absolute_time {
+ "%Y%m%dT%H%M%SZ"
+ } else {
+ "%Y%m%dT%H%M%S"
+ };
+ let time = tz.datetime_from_str(&date, date_pattern).unwrap_or(
+ UTC.timestamp(0, 0),
);
Date::Time(time)
}