[ 
https://issues.apache.org/jira/browse/ARROW-15904?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Todd Farmer reassigned ARROW-15904:
-----------------------------------

    Assignee:     (was: Rok Mihevc)

This issue was last updated over 90 days ago, which may be an indication it is 
no longer being actively worked. To better reflect the current state, the issue 
is being unassigned. Please feel free to re-take assignment of the issue if it 
is being actively worked, or if you plan to start that work soon.

> [C++] Support rolling backwards and forwards with temporal arithmetic
> ---------------------------------------------------------------------
>
>                 Key: ARROW-15904
>                 URL: https://issues.apache.org/jira/browse/ARROW-15904
>             Project: Apache Arrow
>          Issue Type: Sub-task
>          Components: C++
>            Reporter: Dragoș Moldovan-Grünfeld
>            Priority: Blocker
>
> Original description in ARROW-11090: 
> "This should also cover the ability to do with and without rollback (so have 
> the ability to do e.g. 2021-03-30 minus 1 month and either get a null back, 
> or 2021-02-28), plus the ability to specify whether to rollback to the first 
> or last, and whether to preserve or rest the time.)"
> For example, in R, lubridate has the following functionality:
> * {{rollbackward()}} or {{rollback()}} which changes a date to the last day 
> of the previous month or to the first day of the current month
> * {{rollforward()}} which rolls to the last day of the current month or to 
> the first day of the next month.
> * all of the above also offer the option to preserve hms (hours, minutes and 
> seconds) when rolling. 
> This functionality underpins functions such as {{%m-%}} and {{%m+%}} which 
> are used to add or subtract months to a date without exceeding the last day 
> of the new month.
> {code:r}
> library(lubridate)
> jan <- ymd_hms("2010-01-31 03:04:05")
> jan + months(1:3) # Feb 31 and April 31 returned as NA
> #> [1] NA                        "2010-03-31 03:04:05 UTC"
> #> [3] NA
> # NA "2010-03-31 03:04:05 UTC" NA
> jan %m+% months(1:3) # No rollover
> #> [1] "2010-02-28 03:04:05 UTC" "2010-03-31 03:04:05 UTC"
> #> [3] "2010-04-30 03:04:05 UTC"
> leap <- ymd("2012-02-29")
> "2012-02-29 UTC"
> #> [1] "2012-02-29 UTC"
> leap %m+% years(1)
> #> [1] "2013-02-28"
> leap %m+% years(-1)
> #> [1] "2011-02-28"
> leap %m-% years(1)
> #> [1] "2011-02-28"
> x <- ymd_hms("2019-01-29 01:02:03")
> add_with_rollback(x, months(1))
> #> [1] "2019-02-28 01:02:03 UTC"
> add_with_rollback(x, months(1), preserve_hms = FALSE)
> #> [1] "2019-02-28 UTC"
> add_with_rollback(x, months(1), roll_to_first = TRUE)
> #> [1] "2019-03-01 01:02:03 UTC"
> add_with_rollback(x, months(1), roll_to_first = TRUE, preserve_hms = FALSE)
> #> [1] "2019-03-01 UTC"
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to