A type for ``datetime.time()`` objects.
| 925 | |
| 926 | |
| 927 | class 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 | |
| 965 | class _Binary(TypeEngine[bytes]): |
no outgoing calls
no test coverage detected