Skip to content

Refactor the qtr functions - #168

Open
Moohan wants to merge 4 commits into
masterfrom
refactor_qtr
Open

Refactor the qtr functions#168
Moohan wants to merge 4 commits into
masterfrom
refactor_qtr

Conversation

@Moohan

@Moohan Moohan commented Feb 18, 2026

Copy link
Copy Markdown
Member

The quarter functions (qtr(), qtr_end(), qtr_next() and qtr_prev()) shared a large amount of duplicated logic. This PR consolidates the implementation into a single internal helper, reducing code duplication and making the code easier to maintain without changing user-facing behaviour.

The refactor also replaces lubridate::quarter() / lubridate::year() with direct extraction via as.POSIXlt(). Benchmarks across a range of vector sizes and input types showed the new implementation to be consistently 20–30% faster while remaining equivalent to the previous implementation.

Comment thread R/qtr.R Outdated
Comment thread R/qtr.R
There was a lot of duplication in the code that made it quite complicated / confusing. This PR refactors the duplicated code into a single internal function
Moohan added 3 commits July 16, 2026 16:20
Use rlang::caller_call() so the error still 'comes from' the user-facing function.
# This is the 1st commit message:

replaced lubridate::quarter() and lubridate::year() with direct extraction via as.POSIXlt()
# This is the commit message #2:

Style code (GHA)

# This is the commit message #3:

Document package (GHA)
…ction via as.POSIXlt()

Style code (GHA)

Document package (GHA)
@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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

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.

2 participants