Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…37445) ### Rationale for this change Now that `arrow.type.Date32Type` class has been added to the MATLAB Interface (apache#37348), we can add the `arrow.array.Date32Array` class. `Date32Array`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.Date32Array` class. 2. Added a new `arrow.type.traits.Date32Traits` class. 3. Added `arrow.type.Date32Type` support to `arrow.type.traits.traits` function. 4. Fixed typo `arrray` in `tTime32Array` test class. 5. Fixed bug in `numeric_array.h` where the `CType` rather than the `ArrowType` was being used to determine the `DataType` of an array class that is a `NumericArray<T>`. `Date32Array`s can be created from MATLAB [`datetime`](https://www.mathworks.com/help/matlab/ref/datetime.html) values using the `fromMATLAB` method. `Date32Array`s can be converted to MATLAB `datetime` values using the `toMATLAB` method. **Example** ```matlab >> dates = [datetime(2021, 1, 2, 3, 4, 5), datetime(2023, 1, 1), datetime(1989, 2, 3, 10, 10, 10)]' dates = 3x1 datetime array 02-Jan-2021 03:04:05 01-Jan-2023 00:00:00 03-Feb-1989 10:10:10 >> array = arrow.array.Date32Array.fromMATLAB(dates) array = [ 2021-01-02, 2023-01-01, 1989-02-03 ] >> array.toMATLAB() ans = 3x1 datetime array 02-Jan-2021 01-Jan-2023 03-Feb-1989 ``` ### Are these changes tested? Yes. 1. Added a new `tDate32Array` test class. 2. Added `Date32` related test to `ttraits.m`. 6. Added a new `tDate32Traits.m` test class. ### Are there any user-facing changes? Yes. 1. Users can now create `arrow.array.Date32Array`s from MATLAB `datetime`s. ### Future Directions 1. apache#37230 2. Add `arrow.array.Date64Array`. 3. Add a way to extract the raw `int32` values from an `arrow.array.Date32Array` without converting to a MATLAB `datetime` using `toMATLAB`. ### Notes 1. Thank you @ sgilmore10 for your help with this pull request! * Closes: apache#37367 Lead-authored-by: Kevin Gurney <kgurney@mathworks.com> Co-authored-by: Sarah Gilmore <sgilmore@mathworks.com> Signed-off-by: Sutou Kouhei <kou@clear-code.com>
- Loading branch information