Skip to content

Conversation

artemklevtsov
Copy link

First implementation with some POSIXlt calls.
Should closes #4335.

@codecov
Copy link

codecov bot commented Jan 8, 2021

Codecov Report

Merging #4868 (13dd733) into master (b1b1832) will decrease coverage by 0.14%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
R/IDateTime.R 100.00% <100.00%> (ø)
src/fastmean.c 96.82% <0.00%> (-3.18%) ⬇️
src/uniqlist.c 98.25% <0.00%> (-1.75%) ⬇️
src/between.c 99.21% <0.00%> (-0.79%) ⬇️
src/subset.c 99.50% <0.00%> (-0.50%) ⬇️
src/frollR.c 99.53% <0.00%> (-0.47%) ⬇️
src/forder.c 99.61% <0.00%> (-0.39%) ⬇️
src/gsumm.c 99.61% <0.00%> (-0.39%) ⬇️
src/dogroups.c 99.66% <0.00%> (-0.34%) ⬇️
src/assign.c 99.70% <0.00%> (-0.30%) ⬇️
... and 33 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b1b1832...13dd733. Read the comment docs.

@@ -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, ...) {
Copy link
Member

@MichaelChirico MichaelChirico Mar 15, 2024

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)

@MichaelChirico
Copy link
Member

Let's make this behave like round.IDate() (for truncation instead of rounding) once #6024 is resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

trunc.IDate/round.IDate behaviour
3 participants