Skip to content

differenceInYears() returns -0 when comparing the same date #692

Closed
@hanshenrik

Description

differenceInYears('2018-02-01',` '2018-02-01')
// -0

differenceInYears(new Date(), new Date())
// -0

differenceInYears('2018-02-02', '2018-02-01')
// 0

Shouldn't the same year always be returned as a "positive" zero value?

Solvable by using Math.abs(value) if the value is 0. Perhaps a bigger discussion if all values should be returned as positive numbers.

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions