File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -51,13 +51,13 @@ def _convert_monotonic(m):
5151def _convert_source_monotonic (s ):
5252 return _datetime .timedelta (microseconds = int (s ))
5353
54+ _LOCAL_TIMEZONE = _datetime .datetime .now ().astimezone ().tzinfo
5455
5556def _convert_realtime (t ):
56- return _datetime .datetime .fromtimestamp (t / 1000000 )
57-
57+ return _datetime .datetime .fromtimestamp (t / 1000000 , _LOCAL_TIMEZONE )
5858
5959def _convert_timestamp (s ):
60- return _datetime .datetime .fromtimestamp (int (s ) / 1000000 )
60+ return _datetime .datetime .fromtimestamp (int (s ) / 1000000 , _LOCAL_TIMEZONE )
6161
6262
6363def _convert_trivial (x ):
Original file line number Diff line number Diff line change @@ -290,6 +290,18 @@ def test_reader_convert_entry(tmpdir):
290290 'x2' : ['YYY' , 'YYY' ],
291291 'y2' : [b'\200 \200 ' , b'\200 \201 ' ]}
292292
293+ def test_reader_convert_timestamps (tmpdir ):
294+ j = journal .Reader (path = tmpdir .strpath )
295+
296+ val = j ._convert_field ('_SOURCE_REALTIME_TIMESTAMP' , 1641651559324187 )
297+ assert val .tzinfo is not None
298+
299+ val = j ._convert_field ('__REALTIME_TIMESTAMP' , 1641651559324187 )
300+ assert val .tzinfo is not None
301+
302+ val = j ._convert_field ('COREDUMP_TIMESTAMP' , 1641651559324187 )
303+ assert val .tzinfo is not None
304+
293305def test_seek_realtime (tmpdir ):
294306 j = journal .Reader (path = tmpdir .strpath )
295307
You can’t perform that action at this time.
0 commit comments