Open philolo1 opened 10 months ago
I think it has to do with the fact that its Aug28th on JST but AUG 27th on UTC.
Interestingly the tests work at 9:15 JST.
I ran into this issue in my unit tests, which pass in the morning and fail in the evening (I'm in Pacific time, UTC-8). I believe the root cause of this issue is in parse_relative_time.rs
:
pub fn parse_relative_time(s: &str) -> Result<Duration, ParseDateTimeError> {
parse_relative_time_at_date(Utc::now().date_naive(), s)
}
...
pub fn parse_relative_time_at_date(
date: NaiveDate,
s: &str,
) -> Result<Duration, ParseDateTimeError> {
...
if captures_processed == 0 {
Err(ParseDateTimeError::InvalidInput)
} else {
let time_now = Local::now().date_naive();
let date_duration = date - time_now;
Ok(total_duration + date_duration)
}
}
In other words, parse_relative_time
is passing in a Utc::now
, and then we're subtracting a Local::now
date, which definitely isn't going to work if the offset between Utc
and Local
crosses midnight. Any progress towards a fix on this?
Nice find! Feel free to open a PR!
I ran
cargo test
on the current repo and got two errors:I did not get the errors before, so it might have to do with the my timezone. It looks like there might be an error or a different usage between JST and UTC.