CurtHagenlocher commented on code in PR #36125:
URL: https://github.com/apache/arrow/pull/36125#discussion_r1265801126


##########
csharp/src/Apache.Arrow/Arrays/Time64Array.cs:
##########
@@ -113,5 +134,33 @@ public Time64Array(ArrayData data)
                 _ => throw new InvalidDataException($"Unsupported time unit 
for Time64Type: {unit}")
             };
         }
+
+#if NET6_0_OR_GREATER
+        /// <summary>
+        /// Get the time at the specified index as <see cref="TimeOnly"/>
+        /// </summary>
+        /// <remarks>
+        /// This may cause truncation of nanosecond values, as the resolution 
of TimeOnly is in 100-ns increments.
+        /// </remarks>
+        /// <param name="index">Index at which to get the time.</param>
+        /// <returns>Returns a <see cref="TimeOnly" />, or <c>null</c> if 
there is no object at that index.
+        /// </returns>
+        public TimeOnly? GetTime(int index)
+        {
+            long? value = GetValue(index);
+            if (value == null)
+            {
+                return null;
+            }
+
+            var unit = ((Time64Type)Data.DataType).Unit;
+            return unit switch
+            {
+                TimeUnit.Microsecond => new TimeOnly(value.Value * 
TicksPerMicrosecond),
+                TimeUnit.Nanosecond => new TimeOnly(value.Value / 
NanosecondsPerTick),

Review Comment:
   Yes, unfortunately. You'd need to keep it in integer form to deal with 
higher precision.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to