You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/07/18 20:00:53 UTC

[GitHub] [arrow] jonkeane commented on a diff in pull request #13440: ARROW-14819: [R] Binding for lubridate::qday

jonkeane commented on code in PR #13440:
URL: https://github.com/apache/arrow/pull/13440#discussion_r923805105


##########
r/R/dplyr-funcs-datetime.R:
##########
@@ -209,6 +209,13 @@ register_bindings_datetime_components <- function() {
     build_expr("month", x)
   })
 
+  register_binding("lubridate::qday", function(x) {
+    # We calculate day of quarter by flooring timestamp to beginning of quarter and
+    # calculating days between beginning of quarter and timestamp/date in question.
+    floored_x <- build_expr("floor_temporal", x, options = list(unit = 9L))
+    build_expr("days_between", floored_x, x) + Expression$scalar(1L)

Review Comment:
   This is extremely minor, and take it or leave it: but it did take me a second to think through why we are adding 1 here. Maybe we could add it to the comment up above?



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org