Completed
Push — master ( a0c5cf...fb555e )
by Ramon
19s queued 11s
created

default_timezone_serializer()   A

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
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