MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / Time

Class Time

lib/sqlalchemy/sql/sqltypes.py:927–962  ·  view source on GitHub ↗

A type for ``datetime.time()`` objects.

Source from the content-addressed store, hash-verified

925
926
927class Time(_RenderISO8601NoT, HasExpressionLookup, TypeEngine[dt.time]):
928 """A type for ``datetime.time()`` objects."""
929
930 __visit_name__ = "time"
931
932 operator_classes = OperatorClass.DATETIME
933
934 def __init__(self, timezone: bool = False):
935 self.timezone = timezone
936
937 def get_dbapi_type(self, dbapi):
938 return dbapi.DATETIME
939
940 @property
941 def python_type(self):
942 return dt.time
943
944 def _resolve_for_literal(self, value):
945 with_timezone = value.tzinfo is not None
946 if with_timezone and not self.timezone:
947 return TIME_TIMEZONE
948 else:
949 return self
950
951 @util.memoized_property
952 def _expression_adaptations(self):
953 # Based on
954 # https://www.postgresql.org/docs/current/static/functions-datetime.html.
955
956 return {
957 operators.add: {Date: DateTime, Interval: self.__class__},
958 operators.sub: {Time: Interval, Interval: self.__class__},
959 }
960
961 def literal_processor(self, dialect):
962 return self._literal_processor_time(dialect)
963
964
965class _Binary(TypeEngine[bytes]):

Callers 2

sqltypes.pyFile · 0.85
TimeTZTestClass · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected