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

Bug report: Duration in days when spanning over a month is wrong #2546

Open
bojiwama opened this issue Mar 17, 2025 · 2 comments
Open

Bug report: Duration in days when spanning over a month is wrong #2546

bojiwama opened this issue Mar 17, 2025 · 2 comments
Labels
bug Something isn't working. documentation Improvements or additions to documentation feature-request New feature or request.

Comments

@bojiwama
Copy link

What happened?

The number of days between calculations is wrong.

date(2024-09-06) - date(2024-11-03)
Output: 60
date(2025-02-17) - date(2025-03-17)
Output: 30

The correct output should be 58 and 28.
Other dates may have errors, but some are correct, the following one is correct.
date(2025-02-17) - date(2025-03-16)
Output: 27

The latest version of obsidian and dataview on my windows and android are the same.
I don't know if it's just my problem.

DQL

No response

JS

Dataview Version

0.5.68

Obsidian Version

1.8.9

OS

Windows

@bojiwama bojiwama added the bug Something isn't working. label Mar 17, 2025
@holroy
Copy link
Collaborator

holroy commented Mar 17, 2025

When you calculate durations like that, it tries to humanize the output (or something like that) so it calculates the duration in months (and years) and then if we ask for days it does a very sloppy job saying that a month is just this long.

In general, this is an upstream bug of the date library we use. I'll look into providing a supplemental function for this particular situation, as it's not the first time we've encountered this situation.

@holroy holroy changed the title Bug report Bug report: Duration in days when spanning over a month is wrong Mar 17, 2025
@holroy
Copy link
Collaborator

holroy commented Mar 17, 2025

The full explanation for those interested given in the link below:

https://moment.github.io/luxon/#/math?id=diffs

Now the question becomes, how do we handles these diffs currently, and is there a better way to do this?

@holroy holroy added documentation Improvements or additions to documentation feature-request New feature or request. labels Mar 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working. documentation Improvements or additions to documentation feature-request New feature or request.
Projects
None yet
Development

No branches or pull requests

2 participants