Issue
When a timezone-aware datetime is passed to the Interval, it formats it as if it as if it were timezone-unaware.
Use Case
I encountered this issue while importing time entries from other time trackers via an API in the format 2024-10-23T12:00:00+00:00, then converting them to timezone-aware datetime objects to feed into python-timew. Since I'm currently in a non-UTC timezone, the times were imported into Timewarrior with incorrect datetime values. While I can apply a local fix in my script, it seems beneficial for the project to natively support timezone-aware datetime values.
Solution
Replace datetime.strftime('%Y%m%dT%H%M%S') with datetime.isoformat(timespec='seconds') which handles both timezone-aware and naive datetime objects. The timespec parameter is used to trim off microseconds (if present), as Timewarrior cannot parse them.
Issue
When a timezone-aware
datetimeis passed to theInterval, it formats it as if it as if it were timezone-unaware.Use Case
I encountered this issue while importing time entries from other time trackers via an API in the format
2024-10-23T12:00:00+00:00, then converting them to timezone-awaredatetimeobjects to feed intopython-timew. Since I'm currently in a non-UTC timezone, the times were imported into Timewarrior with incorrectdatetimevalues. While I can apply a local fix in my script, it seems beneficial for the project to natively support timezone-awaredatetimevalues.Solution
Replace
datetime.strftime('%Y%m%dT%H%M%S')withdatetime.isoformat(timespec='seconds')which handles both timezone-aware and naivedatetimeobjects. Thetimespecparameter is used to trim off microseconds (if present), as Timewarrior cannot parse them.