Including UTC offset when using `Timestamps::UtcOffset`?
hismito opened this issue · 1 comments
hismito commented
I create a logger like
simple_logger::SimpleLogger::new()
.with_utc_offset(time::UtcOffset::current_local_offset().unwrap())
.init()
.unwrap();
at the very beginning of main()
to not run into #44
This logger will format all offset-ed timestamps in UTC, which makes them looks like they are in UTC but actually not.
I found the relevant change at 496d76a#diff-b1a35a68f14e696205874893c07fd24fdb88882b47c23cc0e0c80a30c7d53759R435
Maybe we can change it to use TIMESTAMP_FORMAT_OFFSET
instead?
let instant = time::macros::datetime!(2020-03-04 05:06:07.800 +09:00);
println!("{}", instant.format(&TIMESTAMP_FORMAT_UTC).unwrap()); // 2020-03-04T05:06:07.800Z
println!("{}", instant.format(&TIMESTAMP_FORMAT_OFFSET).unwrap()); // 2020-03-04T05:06:07.800+09:00
In the example above, they both leaves 3 digits at fracitional part of second as requsted by #55
borntyping commented
Huh yeah, this is definitely a bug. Timestamps::UtcOffset
should use TIMESTAMP_FORMAT_OFFSET
not TIMESTAMP_FORMAT_UTC
.
I'd welcome a PR to fix this, or will get round to it once I'm next on a machine I can easily do Rust dev on. :)