rok commented on a change in pull request #11026:
URL: https://github.com/apache/arrow/pull/11026#discussion_r703012684



##########
File path: cpp/src/arrow/compute/api_scalar.h
##########
@@ -278,6 +278,23 @@ struct ARROW_EXPORT DayOfWeekOptions : public 
FunctionOptions {
   uint32_t week_start;
 };
 
+struct ARROW_EXPORT WeekOptions : public FunctionOptions {
+ public:
+  explicit WeekOptions(bool week_starts_monday = true, bool count_from_zero = 
false,
+                       bool first_week_in_year = false);
+  constexpr static char const kTypeName[] = "WeekOptions";
+  static WeekOptions Defaults() { return WeekOptions{}; }
+
+  /// What day does the week start with (Monday=true, Sunday=false)
+  bool week_starts_monday;
+  /// Dates from current year that fall into last ISO week of the previous 
year return
+  /// 0 if true and 52 or 53 if false.
+  bool count_from_zero;

Review comment:
       You're right though 
([source](https://rdrr.io/cran/lubridate/src/R/accessors-week.r):
   ```
   week <- function(x)
     (yday(x) - 1) %/% 7 + 1
   
   #' @rdname week
   #' @export
   "week<-" <- function(x, value)
     x <- x + days((value - week(x)) * 7)
   
   .other_week <- function(x, week_start) {
     x <- as.POSIXlt(x)
     date <- make_date(year(x), month(x), day(x))
     wday <- wday(x, week_start = week_start)
     date <- date + (4 - wday)
     jan1 <- as.numeric(make_date(year(date), 1, 1))
     1L + (as.numeric(date) - jan1) %/% 7L
   }
   
   #' @description `isoweek()` returns the week as it would appear in the ISO 
8601
   #'   system, which uses a reoccurring leap week.
   #' @rdname week
   #' @export
   isoweek <- function(x) {
     .other_week(x, 1)
   }
   
   #' @description `epiweek()` is the US CDC version of epidemiological week. It
   #'   follows same rules as `isoweek()` but starts on Sunday. In other parts 
of
   #'   the world the convention is to start epidemiological weeks on Monday,
   #'   which is the same as `isoweek`.
   #'
   #' @rdname week
   #' @export
   epiweek <- function(x) {
     .other_week(x, 7)
   }
   ```




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