Skip to content

Commit 5b6d4fd

Browse files
behrmannkeszybz
authored andcommitted
journal: use datetime.timestamp() instead of int-float-stftime-dance
datetime.timestamp() will already return the time as a float, so returning it as a string and parsing that back to a float can be omitted.
1 parent 8f12291 commit 5b6d4fd

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

src/systemd/journal.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -287,13 +287,7 @@ def seek_realtime(self, realtime):
287287
>>> j.seek_realtime(yesterday)
288288
"""
289289
if isinstance(realtime, _datetime.datetime):
290-
try:
291-
realtime = realtime.astimezone()
292-
except TypeError:
293-
# With python2: Required argument 'tz' (pos 1) not found
294-
pass
295-
296-
realtime = int(float(realtime.strftime("%s.%f")) * 1000000)
290+
realtime = int(realtime.astimezone().timestamp() * 1000000)
297291
elif not isinstance(realtime, int):
298292
realtime = int(realtime * 1000000)
299293
return super(Reader, self).seek_realtime(realtime)

0 commit comments

Comments
 (0)