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
added astimedelta() to Duration #49
Conversation
Hi! |
Hi, To correctly transform a Duration to a timedelta you need a reference date. Otherwise you are just guessing, that a year has 365 days, a month has 30 days, which is not always the case. There was a discussion around this in #42. (There are a couple of other suggestions in that thread that should probably make it into the library). However, I believe the cleanest way would be to use a reference date to convert to a timedelta in a generic way. Otherwise if you make assumptions about the length of a year or a month, you'd be probably better off to be explicit in your code, rather than hiding it in a library. |
Hi @gweis What about having totimedelta() with both start and end None return the time delta with the average month and year? |
Hi @gweis , |
Hi sorry for the late reply, I have never seen a use case where I had a precise duration and only needed an estimate to what date that would lead me. Wouldn't it be the same if you supply a start date of |
Hi @gweis ,
Think of the use case where the duration models a sort of age (e.g., how long to keep some cached data, or how long to keep the private data in the database etc.). You would always use the same duration even though the reference point would constantly change. While I agree that it is perfectly possible to store the duration in days, writing We can also close the issue if you feel strongly about this use case and think that it would add clutter to the library. |
That's exactly my point. What data retention do you promise here? Same with years. Do you promise 365 days or 366 days when you say
Or think of birthdays in terms of age. Someone has lived Fell free to re-open in case if you think I am getting something really, wrong here. |
No description provided.