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

jsons.serializers.default_timezone   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 9
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A default_timezone_serializer() 0 13 1
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