HEX
Server: LiteSpeed
System: Linux us-phx-web1284.main-hosting.eu 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: u300739242 (300739242)
PHP: 8.2.30
Disabled: system, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/jsons/serializers/default_datetime.py
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)