Skip to content
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

Improvement Suggestion: Trimester Option with semester() #1134

Open
dpranjic-r opened this issue Sep 26, 2023 · 1 comment
Open

Improvement Suggestion: Trimester Option with semester() #1134

dpranjic-r opened this issue Sep 26, 2023 · 1 comment

Comments

@dpranjic-r
Copy link

Currently, the semester() accessor function from lubridate does not have an option for more than two semesters per year. It would be helpful if the function offered the option to set the number of semesters and start dates, or at the very least offer a trimester option, with the spring, summer, and fall semesters starting on January 1, May 1, and August 1 (typical start dates at large state universities). Thank you for your time and consideration.

@vspinu
Copy link
Member

vspinu commented Sep 27, 2023

It should be a new function, multimester or varimester, something that would accept a range of months, in your example c(1, 5, 8).

Right now you can floor_date to a date vector (unit argument). So you can construct a vector of 1st of Januarys, Mays, and Augusts and round to those.
Something like this:

> y <- today() + months(1:20)
> month(
+   floor_date(
+     update(y, year = 2000),
+     ISOdate(year = 2000, month = c(1, 5, 8), day = 1)
+   ))
## [1] 8 8 8 1 1 1 1 5 5 5 8 8 8 8 8 1 1 1 1 5

I would consider a PR for the implementation of varimester

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

No branches or pull requests

2 participants