Closed garrettgman closed 8 years ago
That would be very useful to me as well.
As an example, to me, the "end of 2014" is a date of format "2014-12-31 24:00:00", but not "2015-01-01", which does not even contain the substring "2014".
What use pattern do you have in mind? @andreas50 can you please provide an example of when this could be useful? I don't follow the context of this issue.
Five years later, I'm not sure that this would be correct behavior.
Since this would involve special pleading and an uphill battle against R, the use case should be very important.
Having this implemented, if possible at all, would require that every accessor, settor and arithmetic operator in the package should know that there exist such a distinction. After all it's the same instant, 24.00.00 is the same as 00.00.00 of the next day, but named differently.
I am closing it for now as non-feasible. Maybe we can address a specific use case that would disallow arithmetics to jump over the boundary, but that's a topic for a different issue.
As for the implementation, an extra parameter to the print() method could be used to control the display behavior. I agree that it makes no sense to change the application logic of the other methods.
Regarding a use case: I frequently deal with time series data where the observation value pertains to a time period rather than point in time. For example, "the total monthly precipitation in Paris in December 1899". To preserve causality in my analysis, the corresponding observation time has to be exactly at the end of December 1899, which in the lubridate package is printed as "1900-01-01" rather than "1899-12-31 24:00:00". This behavior makes it harder to see which observation value belongs to which time period. (Due to the nature of the analysis, I do not want to represent the data using a monthly time series object such as "ts", because I am mixing and matching multiple time series with different frequencies and many missing values, and because the application logic (such the length of moving averages) is in terms of time intervals rather than number of observations.)
That said, after working with the lubridate package for a few more months, like @garrettgman, I see such behavior as less desirable now, because it would probably be conceptually quite messy and have relatively few users.
an extra parameter to the print()
If the scope is limited only to printing then it should be doable. But then it's a rather marginal feature I would say.
I agree. Better to keep it out in this case.
R automatically rolls it over, but some users have requested to not have it rollover