diff options
author | Daniel <kingdread@gmx.de> | 2020-05-01 12:51:06 +0200 |
---|---|---|
committer | Daniel <kingdread@gmx.de> | 2020-05-01 12:51:06 +0200 |
commit | cb757209d438afe23b5bdbfa5f62d00b195ad367 (patch) | |
tree | 3795c8241933c360bb9be099ede2e0d6e0cb85ca /src/fexpr/grammar.lalrpop | |
parent | 9d5b728ce507334ad3916e2628dab1e0d82f5882 (diff) | |
download | raidgrep-cb757209d438afe23b5bdbfa5f62d00b195ad367.tar.gz raidgrep-cb757209d438afe23b5bdbfa5f62d00b195ad367.tar.bz2 raidgrep-cb757209d438afe23b5bdbfa5f62d00b195ad367.zip |
fix timestamp handling
As it turns out, the "local timestamp" as advertised by arcdps is a bit
misleading, because the timestamp is still in UTC. The "local" refers to
the fact that it can lag behind the server timestamp a bit (but usually
they seem to be within +-1 of each other), not that the timestamp is in
the local timezone.
This makes date handling a bit harder for raidgrep, but thanks to
chrono, not by much. The idea is that we simply deal with Utc pretty
much everywhere, except at the user boundary. This means that
1. Input timestamps for -before and -after are converted to Utc right
after input
2. When outputting, we convert to a local timestamp first
This makes the output consistent with the filenames now (and the "wall
time" that the player saw).
Diffstat (limited to 'src/fexpr/grammar.lalrpop')
-rw-r--r-- | src/fexpr/grammar.lalrpop | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/fexpr/grammar.lalrpop b/src/fexpr/grammar.lalrpop index f193a90..8674b84 100644 --- a/src/fexpr/grammar.lalrpop +++ b/src/fexpr/grammar.lalrpop @@ -10,7 +10,7 @@ use evtclib::Boss; use std::collections::HashSet; use lalrpop_util::ParseError; -use chrono::NaiveDateTime; +use chrono::{DateTime, Local, TimeZone, Utc}; use regex::Regex; grammar; @@ -134,23 +134,25 @@ Boss: Boss = { }), } -Date: NaiveDateTime = { - <l:@L> <d:datetime> =>? NaiveDateTime::parse_from_str(d, "%Y-%m-%d %H:%M:%S") +Date: DateTime<Utc> = { + <l:@L> <d:datetime> =>? Local.datetime_from_str(d, "%Y-%m-%d %H:%M:%S") .map_err(|error| ParseError::User { error: FError { location: l, data: d.into(), kind: error.into(), } - }), - <l:@L> <d:date> =>? NaiveDateTime::parse_from_str(&format!("{} 00:00:00", d), "%Y-%m-%d %H:%M:%S") + }) + .map(|d| d.with_timezone(&Utc)), + <l:@L> <d:date> =>? Local.datetime_from_str(&format!("{} 00:00:00", d), "%Y-%m-%d %H:%M:%S") .map_err(|error| ParseError::User { error: FError { location: l, data: d.into(), kind: error.into(), } - }), + }) + .map(|d| d.with_timezone(&Utc)), } Comma<T>: HashSet<T> = { |