GothenburgBitFactory / tasklib

A Python library for interacting with taskwarrior databases.
http://tasklib.readthedocs.org/en/latest/
BSD 3-Clause "New" or "Revised" License
146 stars 27 forks source link

serializing.py zoneinfo.Zoneinfo object has no attribute 'localize' #95

Closed Apis-Carnica closed 3 years ago

Apis-Carnica commented 3 years ago

Hey there, I had an issue with using tasklib along with taskwiki for managing due dates and opening information splits. The expected result was to have the information split open in vim when pressing the [CR] key over the task, and having the document save without errors when using :w; what instead occurred was an error being thrown (in the title) and an information split not opening as well as an error popping up when I go to save the markdown file.

I've read about a few different methods of alleviating this issue, such as reverting tzlocal version, and would like to share how I fixed the issue (at least as a short-term band-aid). In the serializing.py file, on line 233 in the datetime_normalizer() function, the if value.tzinfo is None condition attempts to convert to a localized datetime object. To fix the error, I converted the Zoneinfo object to string and localized it with pytz.timezone() instead, so the new line(s) look like this:

quickfix = str(local_zone)
localized = pytz.timezone(quickfix).localize(value)

It's not pretty or super efficient, but it's a quickfix that I thought may be useful to some. Thank you for your time and consideration, and feel free to share criticisms with this approach (we are all students after all).

Apis-Carnica commented 3 years ago

The post is a suggestion for those running into issues.