question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Manipulating days with decimal numbers ignores hours

See original GitHub issue

Describe the bug When manipulating a date with unit type day and an arbitrary decimal number does not manipulate the time of the date.

Expected behavior The time is manipulated as well.

Information Stackblitz reproduction: https://stackblitz.com/edit/js-akaprq?file=index.js

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Bykievcommented, Aug 8, 2022

Thanks for your elaborations. I agree that the docs need to at least warn the user about this behavior. I can also understand why you want to behave dayjs the same as momentjs but at some point you have to consider removing bugs that moment had and I would consider this clearly as a bug since most other units are able to subtract/add decimal values. A fix in dayjs 2.0 would be OK. We implemented a workaround for now.

It’s not a bug in moment.js, see explanation here: https://github.com/moment/moment/issues/2430#issuecomment-113832948.

1reaction
BePo65commented, Aug 6, 2022

Of course you are right. IMO one of the basic definitions for dayjs is that it behaves just like moment (ok, there are a few exceptions 😃. In this regard this is at least another difference.

But as this would be a breaking change (if not of the documentation that says nothing about it, so at least regarding the functionality), perhaps this should become an action point for dayjs 2.0.

@iamkun is there a place, where those requirements for dayjs 2.0 could be documented?

PS: @Bykiev you are pretty fast responding to issues 🥇 👍 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it a way to .add() or .subtract() float values? #2430 - GitHub
You can use decimals when adding or subtracting hours, minutes, seconds, or milliseconds, but you can't subdivide days or larger components.
Read more >
Alternate Notation, Part 1: Converting Hours to Days-Hours
Learn how to convert hours to days-hours using string manipulation functions in Excel. ... INT turns a decimal number into the closest full...
Read more >
Too many decimal places when using timedelta - Stack Overflow
This method does ignore the .days attribute. If you have timedeltas with more than 24 hours, use: def custom_format(td): minutes, ...
Read more >
How to Subtract Dates and Times in Excel
Here, the numbers after the decimal represent time, while the number before the decimal represents days. Excel will subtract 1 day and (0.25...
Read more >
Convert Time to Decimal Number in Excel (Hours, Minutes ...
In case you only want the complete/full hour value and ignore the minutes part, use the below formula using INT. =INT(A2*24). Use INT...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found