Skip to content
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

docs: describe deviations and extensions to the OData spec #56

Merged
merged 1 commit into from
Jul 12, 2024

Conversation

OliverHofkens
Copy link
Member

ticket: #54

@OliverHofkens OliverHofkens added the documentation Improvements or additions to documentation label Jul 12, 2024
@OliverHofkens OliverHofkens self-assigned this Jul 12, 2024

It's important to note that the final internal value is still expressed in days,
based on average durations.
Thus, a month simply represents 30.44 days, while a year represents 365.25 days.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good that this is documented, but I find it unintuitive. What's the practical use of months being 30.44 days and years being 365.25 days?

I would expect things to work like this:

  • 2023-01-01 + 1 year = 2024-01-01
  • 2024-01-01 + 1 year = 2025-01-01 (even though 2024 is a leap year, so it's 366 days long)

In other words, the duration would only be converted to days when combined with an actual date.
You could argue that this is still ambiguous though.

In Python, timedelta does not support months or years for this reason (I guess), but date.replace does support changing the year or month.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(For context, this was contributed in #53 by someone external. Can't speak for them of course)

I totally agree, I'm guessing this will mainly be used as a shorthand where accuracy doesn't really matter. E.g. "Give me logs of the past 6 months".
I also agree that the date.replace behaviour would probably be more intuitive. But that would also require us to do the date logic in Python and still converting it to a timedelta before passing it on to whatever backend the user has chosen, since it's infeasible (or straight up impossible) to express that logic on every backend.

@OliverHofkens OliverHofkens merged commit 49d0d63 into master Jul 12, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants