Skip to content

[Bug] useDate - getDiff should be symmetrical #100

@J-Sek

Description

@J-Sek

Context

Vuetify uses Math.floor for most of the calculations, so it is not symmetrical either.

Other adapters:

  • moment: symmetrical
  • date-fns: symmetrical
  • luxon: correct for hours, but non-symmetrical for weeks

Problem

  • when calculating diffs by weeks
    • the result is not symmetrical because of Math.floor
  • when calculating diffs by hours, minutes and seconds
    • the result is not symmetrical because of Math.round
    • it returns -0 instead of 0 (JS quirk we should rather hide)

Suggestion

  • always return based on largestUnit

It would align with current implementation in Vuetify (for positive range) while fixing the values in negative range gaining the symmetry.

Metadata

Metadata

Assignees

Labels

E: useDateComposablebugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions