diff --git a/arrow/src/compute/kernels/temporal.rs b/arrow/src/compute/kernels/temporal.rs index 59388242354..efb82843062 100644 --- a/arrow/src/compute/kernels/temporal.rs +++ b/arrow/src/compute/kernels/temporal.rs @@ -276,7 +276,9 @@ where /// integers. /// /// Monday is encoded as `0`, Tuesday as `1`, etc. -pub fn weekday(array: &PrimitiveArray) -> Result +/// +/// See also [`num_days_from_sunday`] which starts at Sunday. +pub fn num_days_from_monday(array: &PrimitiveArray) -> Result where T: ArrowTemporalType + ArrowNumericType, i64: std::convert::From, @@ -309,10 +311,12 @@ where } /// Extracts the day of week of a given temporal array as an array of -/// integers, starting at Sunday. This is different than [`weekday`] which starts at Monday. +/// integers, starting at Sunday. /// /// Sunday is encoded as `0`, Monday as `1`, etc. -pub fn weekday0(array: &PrimitiveArray) -> Result +/// +/// See also [`num_days_from_monday`] which starts at Monday. +pub fn num_days_from_sunday(array: &PrimitiveArray) -> Result where T: ArrowTemporalType + ArrowNumericType, i64: std::convert::From, @@ -632,7 +636,7 @@ mod tests { let a: PrimitiveArray = vec![Some(1514764800000), None, Some(1550636625000)].into(); - let b = weekday(&a).unwrap(); + let b = num_days_from_monday(&a).unwrap(); assert_eq!(0, b.value(0)); assert!(!b.is_valid(1)); assert_eq!(2, b.value(2)); @@ -651,7 +655,7 @@ mod tests { ] .into(); - let b = weekday0(&a).unwrap(); + let b = num_days_from_sunday(&a).unwrap(); assert_eq!(0, b.value(0)); assert!(!b.is_valid(1)); assert_eq!(1, b.value(2));