Skip to content

Add trunc.IDate#4868

Open
artemklevtsov wants to merge 5 commits intoRdatatable:masterfrom
artemklevtsov:trunc-date
Open

Add trunc.IDate#4868
artemklevtsov wants to merge 5 commits intoRdatatable:masterfrom
artemklevtsov:trunc-date

Conversation

@artemklevtsov
Copy link
Copy Markdown

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

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 8, 2021

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.47%. Comparing base (b1b1832) to head (13dd733).
⚠️ Report is 1945 commits behind head on master.

Additional details and impacted files
@@            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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread inst/tests/tests.Rraw Outdated
Comment thread R/IDateTime.R
years = ISOdate(year(x), 1L, 1L)))
}

trunc.IDate = function (x, units = c("weeks", "months", "quarters", "years"), start.on.monday = TRUE, ...) {
Copy link
Copy Markdown
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
Copy Markdown
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

4 participants