| Total Complexity | 1 |
| Total Lines | 18 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | from datetime import timezone |
||
| 2 | from jsons._dump_impl import dump |
||
| 3 | |||
| 4 | |||
| 5 | def default_timezone_serializer(obj: timezone, **kwargs) -> dict: |
||
| 6 | """ |
||
| 7 | Serialize the given timezone instance to a dict holding the total |
||
| 8 | seconds. |
||
| 9 | :param obj: the timezone instance that is to be serialized. |
||
| 10 | :param kwargs: not used. |
||
| 11 | :return: ``timezone`` as a dict. |
||
| 12 | """ |
||
| 13 | name = obj.tzname(None) |
||
| 14 | offset = dump(obj.utcoffset(None), **kwargs) |
||
| 15 | return { |
||
| 16 | 'name': name, |
||
| 17 | 'offset': offset |
||
| 18 | } |
||
| 19 |