Closed jaganmn closed 1 year ago
An even nicer (and still backwards compatible) interface might be:
library("lubridate")
wday(1:7, from_sunday = 1, to_sunday = 1)
## [1] 1 2 3 4 5 6 7
wday(1:7, from_sunday = 7, to_sunday = 1)
## [1] 2 3 4 5 6 7 1
wday(1:7, from_sunday = 1, to_sunday = 7)
## [1] 7 1 2 3 4 5 6
The default value of from_sunday
is 1 and the default value of to_sunday
is 8 - week_start
, so again anyone doing wday(<numeric>)
without specifying any of the new, optional arguments should see the same behaviour as before.
The same tests with label = TRUE
:
wday(1:7, from_sunday = 1, to_sunday = 1, label = TRUE)
## [1] Sun Mon Tue Wed Thu Fri Sat
## Levels: Sun < Mon < Tue < Wed < Thu < Fri < Sat
wday(1:7, from_sunday = 7, to_sunday = 1, label = TRUE)
## [1] Mon Tue Wed Thu Fri Sat Sun
## Levels: Sun < Mon < Tue < Wed < Thu < Fri < Sat
wday(1:7, from_sunday = 1, to_sunday = 7, label = TRUE)
## [1] Sun Mon Tue Wed Thu Fri Sat
## Levels: Mon < Tue < Wed < Thu < Fri < Sat < Sun
Re: #1025
wday.numeric
gains an optional argumentweek_start_x
indicating the coding of argumentx
. The default value is 7, meaning 1=Sunday, for backwards compatibility. Hence anyone doingwday(<numeric>)
without specifyingweek_start_x
should see the same behaviour as before.Some tests, which could easily go into
test-accessors.R
...