kevingurney opened a new pull request, #37445:
URL: https://github.com/apache/arrow/pull/37445

   ### Rationale for this change
   
   Now that `arrow.type.Date32Type` class has been added to the MATLAB 
Interface (#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. #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!


-- 
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