jsons.serializers.default_date   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 6
dl 0
loc 17
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A default_date_serializer() 0 11 1
1
from datetime import date
2
3
from jsons._datetime_impl import to_str, RFC3339_DATE_PATTERN
4
5
6
def default_date_serializer(obj: date, **kwargs) -> str:
7
    """
8
    Serialize the given date instance to a string. It uses the RFC3339
9
    pattern. If date is a localtime, an offset is provided. If date is
10
    in UTC, the result is suffixed with a 'Z'.
11
    :param obj: the date instance that is to be serialized.
12
    :param kwargs: not used.
13
    :return: ``date`` as an RFC3339 string.
14
    """
15
    return to_str(obj, False, kwargs['fork_inst'],
16
                  RFC3339_DATE_PATTERN)
17