-
Notifications
You must be signed in to change notification settings - Fork 1k
Add trunc.IDate #4868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add trunc.IDate #4868
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4868 +/- ##
==========================================
- Coverage 99.61% 99.47% -0.15%
==========================================
Files 72 73 +1
Lines 13916 14570 +654
==========================================
+ Hits 13862 14493 +631
- Misses 54 77 +23
Continue to review full report at Codecov.
|
@@ -83,6 +83,21 @@ round.IDate = function (x, digits=c("weeks", "months", "quarters", "years"), ... | |||
years = ISOdate(year(x), 1L, 1L))) | |||
} | |||
|
|||
trunc.IDate = function (x, units = c("weeks", "months", "quarters", "years"), start.on.monday = TRUE, ...) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would make this more flexible than cut.Date()
, though I'm not sure the exact signature that's most helpful.
Is this too flexible?
week_start = "Mon"
offset = if (is.numeric(week_start)) (week_start + 2L) %% 7L else switch(week_start,
M = , Mon = , Monday = 4L,
Tu = , Tue = , Tuesday = 5L,
W = , Wed = , Wednesday = 6L,
Th = , Thu = , Thursday = 0L,
F = , Fri = , Friday = 1L,
Sa = , Sat = , Saturday = 2L,
Su = , Sun = , Sunday = 3L)
Let's make this behave like |
First implementation with some POSIXlt calls.
Should closes #4335.