default_timezone_serializer()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 13
rs 10
c 0
b 0
f 0
cc 1
nop 2
1
from datetime import timezone
2
3
from jsons._dump_impl import dump
4
5
6
def default_timezone_serializer(obj: timezone, **kwargs) -> dict:
7
    """
8
    Serialize the given timezone instance to a dict holding the total
9
    seconds.
10
    :param obj: the timezone instance that is to be serialized.
11
    :param kwargs: not used.
12
    :return: ``timezone`` as a dict.
13
    """
14
    name = obj.tzname(None)
15
    offset = dump(obj.utcoffset(None), **kwargs)
16
    return {
17
        'name': name,
18
        'offset': offset
19
    }
20