Skip to content

Commit

Permalink
Simplify code with TimePoint_from_ns and TimePoint_to_ns
Browse files Browse the repository at this point in the history
  • Loading branch information
EnricoMi committed Aug 30, 2024
1 parent 988fef6 commit 0b6d128
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions python/pyarrow/_flight.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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(<CTimePoint>self.endpoint.expiration_time.value())
shared = make_shared[CTimestampScalar](time_since_epoch, time_type)
return Scalar.wrap(<shared_ptr[CScalar]> shared)
return None
Expand Down

0 comments on commit 0b6d128

Please sign in to comment.