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):
51
51
def _convert_source_monotonic (s ):
52
52
return _datetime .timedelta (microseconds = int (s ))
53
53
54
+ _LOCAL_TIMEZONE = _datetime .datetime .now ().astimezone ().tzinfo
54
55
55
56
def _convert_realtime (t ):
56
- return _datetime .datetime .fromtimestamp (t / 1000000 )
57
-
57
+ return _datetime .datetime .fromtimestamp (t / 1000000 , _LOCAL_TIMEZONE )
58
58
59
59
def _convert_timestamp (s ):
60
- return _datetime .datetime .fromtimestamp (int (s ) / 1000000 )
60
+ return _datetime .datetime .fromtimestamp (int (s ) / 1000000 , _LOCAL_TIMEZONE )
61
61
62
62
63
63
def _convert_trivial (x ):
Original file line number Diff line number Diff line change @@ -290,6 +290,18 @@ def test_reader_convert_entry(tmpdir):
290
290
'x2' : ['YYY' , 'YYY' ],
291
291
'y2' : [b'\200 \200 ' , b'\200 \201 ' ]}
292
292
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
+
293
305
def test_seek_realtime (tmpdir ):
294
306
j = journal .Reader (path = tmpdir .strpath )
295
307
You can’t perform that action at this time.
0 commit comments