paleolimbot commented on code in PR #12707:
URL: https://github.com/apache/arrow/pull/12707#discussion_r841827555


##########
r/R/dplyr-funcs-datetime.R:
##########
@@ -309,6 +323,34 @@ register_bindings_duration <- function() {
 
     build_expr("cast", x, options = cast_options(to_type = duration(unit = 
"s")))
   })
+  register_binding("decimal_date", function(date) {
+    y <- build_expr("year", date)
+    start <- call_binding("make_datetime", year = y, tz = "UTC")
+    sofar <- call_binding("difftime", date, start, units = "secs")
+    total <- call_binding(
+      "if_else",
+      build_expr("is_leap_year", date),
+      Expression$scalar(31622400L), # number of seconds in a leap year (366 
days)
+      Expression$scalar(31536000L)  # number of seconds in a regular year (365 
days)
+      )

Review Comment:
   ```suggestion
       )
   ```



##########
r/NEWS.md:
##########
@@ -23,6 +23,7 @@
 * `lubridate`:
   * component extraction functions: `tz()` (timezone), `semester()` 
(semester), `dst()` (daylight savings time indicator), `date()` (extract date), 
`epiyear()` (epiyear), improvements to `month()`, which now works with integer 
inputs.
   * `make_date()` & `make_datetime()` + `ISOdatetime()` & `ISOdate()` to 
create date-times from numeric representations. 
+  * `decimal_date()` and `date_decimal()`

Review Comment:
   ```suggestion
     * Added `decimal_date()` and `date_decimal()`
   ```



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