-
Notifications
You must be signed in to change notification settings - Fork 67
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
Support month unit and proper years in duration #5338
Comments
@chrismo: Indeed, it seems to be one of those problems with no single pure solution, so users are stuck figuring out what compromises they're willing to make and settling for a "good enough" approach that suits their needs. Debates on this topic can be found attached to many of the "duration" libraries for various programming languages, and this StackOverflow post seems to do a decent job of walking through much of the topic. If we can add enhancements that help get closer to "good enough", I expect use case details from users like you or anyone else watching this issue would help a lot. Just doing some general riffing along the lines of how I see other folks coping, some just take the simplistic approach just using an approximate month measured in days, e.g., if trying to find approximately "one month" out from a given timestamp:
Or if you want to be more accurate, maybe use a helper constant:
And I feel like I should point out that for working with calendar months, the
But these are just food for thought absent specific use cases. Folks watching this issue should please speak up with their details. Thanks! |
My use case is working with data like a recurring monthly activity, and I wanted to be able to move a due date forward one month and have it "just work" so that Aug 31st could be moved forward to Sep 30 (last day of the month). The case of going from Sep 30 to Oct 30 vs Oct 31 (last day of month) - there's no way I can think to have a reasonable default other than Oct 30 with just simple duration addition ... but, that would be fine with me if I could do I also know how complicated this stuff can get, and y'all may decide it's out of scope for zed, which would be understandable to me. |
Primitive Values in the 1.18 docs show that "month" is not included unit in the type:
I presume this is because dealing with the varying lengths of months is some work, same as dealing with leap years. I have a use-case working moving dates where having month support would be handy. Instead, I'll drop back to the shell and use GNU date for what I need.
The text was updated successfully, but these errors were encountered: