-
Notifications
You must be signed in to change notification settings - Fork 207
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
Improving time_length for 29 Feb (when dealing with date time) #295
Conversation
A quick comment about period computation from intervals: > naiss <- ymd_hms("1992-02-29 12:00:00")
> evt <- ymd_hms("2014-03-01 01:00:00")
> as.period(interval(naiss, evt))
[1] "22y 0m -1d 13H 0M 0S" Should we avoid negative days? |
This should not happen. It's a bug in as.period.
|
Well. There is a mirror problem with negative intervals that use
So we will have to change %m+% as well, and I am not sure that's a good idea. %m+% will basically make all intraday timestamps for Feb 29 equal, and that's clearly not suitable for intraday analysis. One easy solution is to add an optional argument to BTW. your |
You are right. We can also add I will update the pull request. |
When we think with time, even for negative intervals we should not use Therefore, the code is simpler. Now, we obtain: > time_length(interval(ymd_hms('2000-02-29 12:00:00'), ymd_hms('1999-02-28 20:00:00')), "years")
[1] -1.000457 |
680d4a7
to
f1c22f3
Compare
Two new arguments (roll_to_first and preserve_hms) for rollback and .month_plus. time_length for intervals updated. %m++% not needed anymore.
Tests and examples added for rollback. Code of time_length updated with |
Great! Thanks. |
Improving time_length for 29 Feb (when dealing with date time)
With previous version, we had:
We should consider that the anniversary occurs between 28 Feb at 23:59:59 and 1st March at 00:00:00. Therefore,
%m++%
should rollback at 00:00:00. In that case: