From 0b6d12892efeb6bb5801f84ae0910b57b11238d5 Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Fri, 30 Aug 2024 11:08:28 +0200 Subject: [PATCH] Simplify code with TimePoint_from_ns and TimePoint_to_ns --- python/pyarrow/_flight.pyx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/python/pyarrow/_flight.pyx b/python/pyarrow/_flight.pyx index 98a821660f992..d84d03f157415 100644 --- a/python/pyarrow/_flight.pyx +++ b/python/pyarrow/_flight.pyx @@ -744,8 +744,8 @@ cdef class FlightEndpoint(_Weakrefable): self.endpoint.locations.push_back(c_location) if expiration_time is not None: - self.endpoint.expiration_time = time_point(duration_cast[time_point.duration]( - nanoseconds(expiration_time.cast(timestamp("ns")).value))) + self.endpoint.expiration_time = TimePoint_from_ns( + expiration_time.cast(timestamp("ns")).value) self.endpoint.app_metadata = tobytes(app_metadata) @@ -774,8 +774,7 @@ cdef class FlightEndpoint(_Weakrefable): shared_ptr[CTimestampType] time_type = make_shared[CTimestampType](TimeUnit.TimeUnit_NANO, UTC) shared_ptr[CTimestampScalar] shared if self.endpoint.expiration_time.has_value(): - time_since_epoch = duration_cast[nanoseconds]( - self.endpoint.expiration_time.value().time_since_epoch()).count() + time_since_epoch = TimePoint_to_ns(self.endpoint.expiration_time.value()) shared = make_shared[CTimestampScalar](time_since_epoch, time_type) return Scalar.wrap( shared) return None