# Path: telethon/_misc/helpers.py
# def pretty_print(obj, indent=None, max_depth=float('inf')):
#     max_depth -= 1
#     if max_depth < 0:
#         return '...'
# 
#     to_d = getattr(obj, 'to_dict', None)
#     if callable(to_d):
#         obj = to_d()
# 
#     if indent is None:
#         if isinstance(obj, dict):
#             return '{}({})'.format(obj.get('_', 'dict'), ', '.join(
#                 '{}={}'.format(k, pretty_print(v, indent, max_depth))
#                 for k, v in obj.items() if k != '_'
#             ))
#         elif isinstance(obj, str) or isinstance(obj, bytes):
#             return repr(obj)
#         elif hasattr(obj, '__iter__'):
#             return '[{}]'.format(
#                 ', '.join(pretty_print(x, indent, max_depth) for x in obj)
#             )
#         else:
#             return repr(obj)
#     else:
#         result = []
# 
#         if isinstance(obj, dict):
#             result.append(obj.get('_', 'dict'))
#             result.append('(')
#             if obj:
#                 result.append('\n')
#                 indent += 1
#                 for k, v in obj.items():
#                     if k == '_':
#                         continue
#                     result.append('\t' * indent)
#                     result.append(k)
#                     result.append('=')
#                     result.append(pretty_print(v, indent, max_depth))
#                     result.append(',\n')
#                 result.pop()  # last ',\n'
#                 indent -= 1
#                 result.append('\n')
#                 result.append('\t' * indent)
#             result.append(')')
# 
#         elif isinstance(obj, str) or isinstance(obj, bytes):
#             result.append(repr(obj))
# 
#         elif hasattr(obj, '__iter__'):
#             result.append('[\n')
#             indent += 1
#             for x in obj:
#                 result.append('\t' * indent)
#                 result.append(pretty_print(x, indent, max_depth))
#                 result.append(',\n')
#             indent -= 1
#             result.append('\t' * indent)
#             result.append(']')
# 
#         else:
#             result.append(repr(obj))
# 
#         return ''.join(result)


import base64
import json
import struct
import time
from datetime import datetime, date, timedelta, timezone
from .helpers import pretty_print
    @staticmethod
    def _serialize_datetime(dt):
        if not dt and not isinstance(dt, timedelta):
            return b'\0\0\0\0'

        if isinstance(dt, datetime):
            dt = _datetime_to_timestamp(dt)
        elif isinstance(dt, date):
            dt = _datetime_to_timestamp(datetime(dt.year, dt.month, dt.day))
        elif isinstance(dt, float):
            dt = int(dt)
        elif isinstance(dt, timedelta):
            # Timezones are tricky. datetime.utcnow() + ... timestamp() works
            dt = _datetime_to_timestamp(datetime.utcnow() + dt)

        if isinstance(dt, int):
            return struct.pack('<i', dt)

        raise TypeError('Cannot interpret "{}" as a date.'.format(dt))

    def __eq__(self, o):
        return isinstance(o, type(self)) and self.to_dict() == o.to_dict()

    def __ne__(self, o):
        return not isinstance(o, type(self)) or self.to_dict() != o.to_dict()

    def __repr__(self):
        return pretty_print(self)

    def __str__(self):

# Path: telethon/_misc/helpers.py
# def pretty_print(obj, indent=None, max_depth=float('inf')):
#     max_depth -= 1
#     if max_depth < 0:
#         return '...'
# 
#     to_d = getattr(obj, 'to_dict', None)
#     if callable(to_d):
#         obj = to_d()
# 
#     if indent is None:
#         if isinstance(obj, dict):
#             return '{}({})'.format(obj.get('_', 'dict'), ', '.join(
#                 '{}={}'.format(k, pretty_print(v, indent, max_depth))
#                 for k, v in obj.items() if k != '_'
#             ))
#         elif isinstance(obj, str) or isinstance(obj, bytes):
#             return repr(obj)
#         elif hasattr(obj, '__iter__'):
#             return '[{}]'.format(
#                 ', '.join(pretty_print(x, indent, max_depth) for x in obj)
#             )
#         else:
#             return repr(obj)
#     else:
#         result = []
# 
#         if isinstance(obj, dict):
#             result.append(obj.get('_', 'dict'))
#             result.append('(')
#             if obj:
#                 result.append('\n')
#                 indent += 1
#                 for k, v in obj.items():
#                     if k == '_':
#                         continue
#                     result.append('\t' * indent)
#                     result.append(k)
#                     result.append('=')
#                     result.append(pretty_print(v, indent, max_depth))
#                     result.append(',\n')
#                 result.pop()  # last ',\n'
#                 indent -= 1
#                 result.append('\n')
#                 result.append('\t' * indent)
#             result.append(')')
# 
#         elif isinstance(obj, str) or isinstance(obj, bytes):
#             result.append(repr(obj))
# 
#         elif hasattr(obj, '__iter__'):
#             result.append('[\n')
#             indent += 1
#             for x in obj:
#                 result.append('\t' * indent)
#                 result.append(pretty_print(x, indent, max_depth))
#                 result.append(',\n')
#             indent -= 1
#             result.append('\t' * indent)
#             result.append(']')
# 
#         else:
#             result.append(repr(obj))
# 
#         return ''.join(result)


# Path: telethon/_misc/tlobject.py
import base64
import json
import struct
import time
from datetime import datetime, date, timedelta, timezone
from .helpers import pretty_print

    @staticmethod
    def _serialize_datetime(dt):
        if not dt and not isinstance(dt, timedelta):
            return b'\0\0\0\0'

        if isinstance(dt, datetime):
            dt = _datetime_to_timestamp(dt)
        elif isinstance(dt, date):
            dt = _datetime_to_timestamp(datetime(dt.year, dt.month, dt.day))
        elif isinstance(dt, float):
            dt = int(dt)
        elif isinstance(dt, timedelta):
            # Timezones are tricky. datetime.utcnow() + ... timestamp() works
            dt = _datetime_to_timestamp(datetime.utcnow() + dt)

        if isinstance(dt, int):
            return struct.pack('<i', dt)

        raise TypeError('Cannot interpret "{}" as a date.'.format(dt))

    def __eq__(self, o):
        return isinstance(o, type(self)) and self.to_dict() == o.to_dict()

    def __ne__(self, o):
        return not isinstance(o, type(self)) or self.to_dict() != o.to_dict()

    def __repr__(self):
        return pretty_print(self)

    def __str__(self):

        return pretty_print(self, max_depth=2)