Skip to content

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

@jpsutton

Description

@jpsutton

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions