-
Notifications
You must be signed in to change notification settings - Fork 39
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
Month/year support #7
Comments
Months and years are periods of time directly related to the calendar; they could be included in pytimeparse, but only relative to a particular date (such as the current system time). There's also complications such as leap-years and leap-seconds. For the moment, I chose to only include time expressions which correspond to a fixed length of time. minutes, hours, days: http://tools.ietf.org/html/rfc3339#section-2 |
There are use-cases where years/months support is useful even if not following a calendar, using nominal fixed lengths of time for each. Consider the case where a user specifies an interval for expiration. For example, this cookie is good for "1 month" or delete all records older than "3 years". In these cases, being able to compare a timestamp or datetime against (now - interval) is useful, even if it's not going to be the same time on a wall clock or same day on the calendar. For that reason, I've added months and years support to tempora's parse_timedelta function. It would be useful in these cases if pytimeparse supported parsing months and years, either with a caution in the docs about what that means or even a UserWarning that an implementer may choose to suppress to acknowledge the potential pitfalls. |
+1. This would be extremely useful for reasons @jaraco listed. Had to fork pytimeparse just for that little uncomment. Please give this issue another consideration. |
@wroberts Could you perhaps add a flag to the module that enables using months and years that users must explicitly set in order for those functions to work? e.g.
You could use the average length of a month (30.42 days) and the average length of a year (365.25 days) to make it slightly more precise for general usage. It is worth noting that that is what wolframalpha.com does: |
I see that its commented in the code, any reason for that?
The text was updated successfully, but these errors were encountered: