jsons.serializers.default_timezone   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 9
dl 0
loc 19
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
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