I have an application that uses cysystemd.JournalReader to read and report systemd log entries. I noticed that the timestamps were off by 4 hours (I am GMT-4).
After looking into the issue we concluded that changing our usage from
The line in question could be updated to date = datetime.fromtimestamp(self.get_realtime_sec(), timezone.utc) to resolve the issue.
Or the two liner version would be
date = datetime.utcfromtimestamp(self.get_realtime_sec())
date = date.replace(tzinfo=timezone.utc)
I have an application that uses cysystemd.JournalReader to read and report systemd log entries. I noticed that the timestamps were off by 4 hours (I am GMT-4).
After looking into the issue we concluded that changing our usage from
to
resolved the issue.
I did some reading into the cysystemd code and noticed that you attempt to correct for this here https://github.com/mosquito/cysystemd/blob/master/cysystemd/reader.pyx#L248-L249 But do so unsuccessfully because
datetime.replace
returns a new object that you do not capture.The line in question could be updated to
date = datetime.fromtimestamp(self.get_realtime_sec(), timezone.utc)
to resolve the issue. Or the two liner version would be