kevingurney opened a new pull request, #37581: URL: https://github.com/apache/arrow/pull/37581
### Rationale for this change Now that `arrow.type.Date64Type` class has been added to the MATLAB Interface (#37578), we can add the `arrow.array.Date64Array` class. `Date64Array`s can be created from MATLAB [`datetime`](https://www.mathworks.com/help/matlab/ref/datetime.html) values. ### What changes are included in this PR? 1. Added a new `arrow.array.Date64Array` class. 2. Added a new `arrow.type.traits.Date64Traits` class. 3. Added `arrow.type.Date64Type` support to `arrow.type.traits.traits` function. 4. Factored out `convertToEpochTime` method on `TimestampArray` into internal helper function `arrow.array.internal.temporal.convertDatetimeToEpochTime`. `Date64Array`s can be created from MATLAB [`datetime`](https://www.mathworks.com/help/matlab/ref/datetime.html) values using the `fromMATLAB` method. `Date64Array`s can be converted to MATLAB `datetime` values using the `toMATLAB` method. **Example** ```matlab >> dates = datetime + milliseconds(1:5)' dates = 5×1 datetime array 05-Sep-2023 16:47:12 05-Sep-2023 16:47:12 05-Sep-2023 16:47:12 05-Sep-2023 16:47:12 05-Sep-2023 16:47:12 % "SSS" displays fractional seconds (i.e. milliseconds) >> dates.Format = "MMM dd, yyyy HH:mm:ss SSS" dates = 5×1 datetime array Sep 05, 2023 16:47:12 933 Sep 05, 2023 16:47:12 934 Sep 05, 2023 16:47:12 935 Sep 05, 2023 16:47:12 936 Sep 05, 2023 16:47:12 937 >> array = arrow.array.Date64Array.fromMATLAB(dates) array = [ 2023-09-05, 2023-09-05, 2023-09-05, 2023-09-05, 2023-09-05 ] >> array.toMATLAB ans = 5×1 datetime array 05-Sep-2023 16:47:12 05-Sep-2023 16:47:12 05-Sep-2023 16:47:12 05-Sep-2023 16:47:12 05-Sep-2023 16:47:12 % Milliseconds are preserved on round-trip >> ans.Format = "MMM dd, yyyy HH:mm:ss SSS" ans = 5×1 datetime array Sep 05, 2023 16:47:12 933 Sep 05, 2023 16:47:12 934 Sep 05, 2023 16:47:12 935 Sep 05, 2023 16:47:12 936 Sep 05, 2023 16:47:12 937 ``` ### Are these changes tested? 1. Added a new `tDate64Array` test class. 2. Added `Date64` related test to `ttraits.m`. 3. Added a new `tDate64Traits.m` test class. ### Are there any user-facing changes? Yes. 1. Users can now create `arrow.array.Date64Array`s from MATLAB `datetime`s. ### Future Directions 1. Add round-trip precision tests for `TimestampArray` (i.e. similar to the test case `TestInt64MaxMilliseconds`). 2. Add a way to extract the raw `int64` values from an `arrow.array.Date64Array` without converting to a MATLAB `datetime` using `toMATLAB`. ### Notes 1. Thank you @sgilmore10 for your help with this pull request! -- 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]
