emabee / flexi_logger

A flexible logger for rust programs that can write to stderr, stdout, and/or to log files
Apache License 2.0
307 stars 50 forks source link

`DeferredNow::format_rfc3339` uses wrong timezone information #133

Closed hasezoey closed 1 year ago

hasezoey commented 1 year ago

Currently the timezone is defined with a Z but given a local time, but this will actually result in the wrong time https://github.com/emabee/flexi_logger/blob/b2447d08550b298a2f356e4ac725e402733f0484/src/deferred_now.rs#L52

for example in my current timezone which is Europe/Berlin (+1h) the following happens:

name time
actual UTC time 2023-01-14T16:16:34.000Z
current function output 2023-01-14T17:16:34.000Z
using %Z 2023-01-14T17:16:34.000+01:00
using %z 2023-01-14T17:16:34.000+0100
using just %+ 2023-01-14T17:16:34.000000000+01:00
for reference JS .toISOString would output*1 2023-01-14T16:16:34.000Z

*1 given the time of 2023-01-14T17:16:34.000+01:00 (from using %Z)

possible fixes: