Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timestamp logic does not correctly handle datetime objects with tzinfo #2

Open
jpsutton opened this issue May 24, 2023 · 0 comments
Open

Comments

@jpsutton
Copy link

jpsutton commented May 24, 2023

The log function accepts a timestamp param which, if not provided, will get automatically populated with a UTC-based timestamp of the current time (via the datetime2rfc3339 function). If, however, the user provides this param with a datetime object, then any attached tzinfo is ignored, and that object is only correctly handled if the timestamp is in the recent past (less than 30 minutes ago).

If one provides a timestamp which is further in the past than a half hour from the current time, then an incorrect timezone offset is calculated, effectively making the timestamp itself incorrect in the resulting syslog message header.

If one replaces the contents of datetime2rfc3339 with return dt.isoformat(), I believe this will always produce a valid syslog timestamp (compared against the RFC document).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant