Commits


sgilmore10 authored and GitHub committed 0781f134144
GH-37290: [MATLAB] Add `arrow.array.Time32Array` class (#37315) ### Rationale for this change Now that the `arrow.type.Time32Type` class has been added to the MATLAB Interface (#37250), we can add the `arrow.array.Time32Array` class. ### What changes are included in this PR? 1. Added a new class `arrow.array.Time32Array`. It has the following read-only properties: `Type` and `Length`. It has the following methods: `fromMATLAB()`, `toMATLAB()`, and `duration()`. For reference, `duration` arrays in MATLAB represent lengths of time in fixed-length units. Here's a [link](https://www.mathworks.com/help/matlab/ref/duration.html) to the documentation. 2. Added a new class called `arrow.type.traits.Time32Traits`. **Example Usage** ```matlab >> times = seconds([100 120 NaN 200]) times = 1×4 duration array 100 sec 120 sec NaN sec 200 sec >> time32Array = arrow.array.Time32Array.fromMATLAB(times) time32Array = [ 00:01:40, 00:02:00, null, 00:03:20 ] >> roundtrip = toMATLAB(time32Array) roundtrip = 4×1 duration array 100 sec 120 sec NaN sec 200 sec ``` You can also specify the `TimeUnit` to use via a name-value pair. `TimeUnit` can either be `"Second"` (default) or `"Milisecond"`. ```matlab >> times = seconds([100 120 NaN 200]); >> time32Array = arrow.array.Time32Array.fromMATLAB(times, TimeUnit="Millisecond") time32Array = [ 00:01:40.000, 00:02:00.000, null, 00:03:20.000 ] ``` ### Are these changes tested? Yes. Added two new test classes: `tTime32Array.m` and `tTime32Traits.m`. ### Are there any user-facing changes? Yes, users can now create `arrow.array.Time32Array`s from MATLAB `duration`s via the static `fromMATLAB` method on `arrow.array.Time32Array`. ### Future Directions 1. Add `arrow.array.Time64Array` 2. Add `arrow.type.Date32Type` and `arrow.array.Date32Array` 4. Add `arrow.type.Date64Type` and `arrow.array.Date64Array` * Closes: #37290 Authored-by: Sarah Gilmore <sgilmore@mathworks.com> Signed-off-by: Sutou Kouhei <kou@clear-code.com>