comment here

This commit is contained in:
ton
2023-03-18 20:03:34 +07:00
commit 4553a0a589
14513 changed files with 2685043 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
from datetime import datetime
from typing import Optional
from jsons._datetime_impl import to_str, RFC3339_DATETIME_PATTERN
def default_datetime_serializer(obj: datetime,
*,
strip_microseconds: Optional[bool] = False,
**kwargs) -> str:
"""
Serialize the given datetime instance to a string. It uses the RFC3339
pattern. If datetime is a localtime, an offset is provided. If datetime is
in UTC, the result is suffixed with a 'Z'.
:param obj: the datetime instance that is to be serialized.
:param strip_microseconds: determines whether microseconds should be
omitted.
:param kwargs: not used.
:return: ``datetime`` as an RFC3339 string.
"""
return to_str(obj, strip_microseconds, kwargs['fork_inst'],
RFC3339_DATETIME_PATTERN)