Repository: ramonhagenaars/jsons

Issue:
zoneinfo support incomplete
As the following REPL session seems to show, `zoneinfo` support in version `1.5.0` is incomplete. The standalone `dump` of `ZoneInfo` works, but when constructing a `datetime` with `tzinfo` , the nested dump doesn't work.

```
>>> import jsons
>>> from zoneinfo import ZoneInfo
>>> info = ZoneInfo(key='America/Los_Angeles')
>>> di = jsons.dump(info)
>>> di
{'key': 'America/Los_Angeles'}
>>> from datetime import datetime, timedelta
>>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles"))
>>> jdt = jsons.dump(dt)
Traceback (most recent call last):
  File "C:\Users\jeff1\Documents\projects\git\cdk\r53\.venv\lib\site-packages\jsons\_dump_impl.py", line 60, in _do_dump
    result = serializer(obj, cls=cls, **kwargs)
  File "C:\Users\jeff1\Documents\projects\git\cdk\r53\.venv\lib\site-packages\jsons\serializers\default_datetime.py", line 21, in default_datetime_serializer
    return to_str(obj, strip_microseconds, kwargs['fork_inst'],
  File "C:\Users\jeff1\Documents\projects\git\cdk\r53\.venv\lib\site-packages\jsons\_datetime_impl.py", line 20, in to_str
    offset = get_offset_str(dt, fork_inst)
  File "C:\Users\jeff1\Documents\projects\git\cdk\r53\.venv\lib\site-packages\jsons\_datetime_impl.py", line 37, in get_offset_str
    result = _datetime_offset_str(obj, fork_inst)
  File "C:\Users\jeff1\Documents\projects\git\cdk\r53\.venv\lib\site-packages\jsons\_datetime_impl.py", line 76, in _datetime_offset_str
    tdelta = tzone.utcoffset(None) or tzone.adjusted_offset
AttributeError: 'zoneinfo.ZoneInfo' object has no attribute 'adjusted_offset'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\jeff1\Documents\projects\git\cdk\r53\.venv\lib\site-packages\jsons\_dump_impl.py", line 55, in dump
    return _do_dump(obj, serializer, cls, initial, kwargs_)
  File "C:\Users\jeff1\Documents\projects\git\cdk\r53\.venv\lib\site-packages\jsons\_dump_impl.py", line 66, in _do_dump
    raise SerializationError(str(err)) from err
jsons.exceptions.SerializationError: 'zoneinfo.ZoneInfo' object has no attribute 'adjusted_offset'
```



Discussion:

Patch:
diff --git a/README.md b/README.md
index 70892fd..15af1d1 100644
--- a/README.md
+++ b/README.md
@@ -81,6 +81,10 @@ list_of_tuples = jsons.load(some_dict, List[Tuple[AClass, AnotherClass]])
 
 ## Recent updates
 
+### 1.5.1
+
+- Bugfix: `ZoneInfo` failed to dump if attached to a `datetime`.
+
 ### 1.5.0
 
 - Feature: Support for `ZoneInfo` on Python3.9+.
diff --git a/jsons/_datetime_impl.py b/jsons/_datetime_impl.py
index 6b0d734..575d9a6 100644
--- a/jsons/_datetime_impl.py
+++ b/jsons/_datetime_impl.py
@@ -73,7 +73,8 @@ def _datetime_offset_str(obj: datetime, fork_inst: type) -> str:
             return '+00:00'
     offset = 'Z'
     if tzone.tzname(None) not in ('UTC', 'UTC+00:00'):
-        tdelta = tzone.utcoffset(None) or tzone.adjusted_offset
+        tdelta = tzone.utcoffset(None) or \
+                 getattr(tzone, 'adjusted_offset', tzone.utcoffset(obj))
         offset = _timedelta_offset_str(tdelta)
     return offset
 
diff --git a/jsons/_meta.py b/jsons/_meta.py
index fe65e9f..8c60d77 100644
--- a/jsons/_meta.py
+++ b/jsons/_meta.py
@@ -1,5 +1,5 @@
 __title__ = 'jsons'
-__version__ = '1.5.0'
+__version__ = '1.5.1'
 __author__ = 'Ramon Hagenaars'
 __author_email__ = 'ramon.hagenaars@gmail.com'
 __description__ = 'For serializing Python objects to JSON (dicts) and back'


Test patch:
diff --git a/tests/test_specific_versions.py b/tests/test_specific_versions.py
index 341df74..6a699ee 100644
--- a/tests/test_specific_versions.py
+++ b/tests/test_specific_versions.py
@@ -1,5 +1,6 @@
 import sys
 import uuid
+from datetime import datetime
 from pathlib import Path
 from unittest import TestCase, skipUnless
 
@@ -146,7 +147,7 @@ class TestSpecificVersions(TestCase):
         self.assertDictEqual(expected2, dumped2)
 
     @only_version_3(9, and_above=True)
-    def test_postponed_annoation_dataclass(self):
+    def test_zoneinfo(self):
         # On Python 3.9 ZoneInfo should be available.
 
         from zoneinfo import ZoneInfo
@@ -154,9 +155,13 @@ class TestSpecificVersions(TestCase):
         info = ZoneInfo(key='America/Los_Angeles')
         dumped_info = jsons.dump(info)
         loaded_info = jsons.load(dumped_info, ZoneInfo)
-
         self.assertEqual(info, loaded_info)
 
+        dt = datetime(2021, 8, 31, tzinfo=ZoneInfo("America/Los_Angeles"))
+        dumped_dt = jsons.dump(dt)
+        loaded_dt = jsons.load(dumped_dt, datetime)
+        self.assertEqual(dt, loaded_dt)
+
     @only_version_3(9, and_above=True)
     def test_dump_load_parameterized_collections(self):
         import version_39