Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign updmonths and dyears incorrectly defined #889
Comments
|
You are right about dmonth not being exported. Regarding your other problem, it's as expected. durations are fixed, and dmonth and dyear are average durations. This is documented. What you need is a > ymd("2020-01-01") + dyears(1)
[1] "2021-01-01" |
|
Why is this closed? |
|
it is in v1.7.9
|
Adding dmonths and dyears to dates does not yield correct values because they are defined in terms of seconds. Furthermore, dmonths was added in 1.7.8 but not exported. To correct, durations must be reimplemented to account for irregular duration lengths.
The underlying problem is the duration of a month or a year depends on the particular month or year. 1972-02 has 29 days, while 1972-03 has 31. 1972 has 366 days, while 1973 has 365 days. Adding these durations to dates needs to reflect this. The duration object should be reimplemented to reflect this lack of regularity. (The absence of support for leap seconds also indicates the need for a fundamental reimplementation of durations.)