tidyverts / tsibble

Tidy Temporal Data Frames and Tools
https://tsibble.tidyverts.org
GNU General Public License v3.0
528 stars 50 forks source link

yearmonth("2020-01-01") == yearmonth("2020-01-02") is FALSE #226

Closed zzawadz closed 3 years ago

zzawadz commented 3 years ago

yearmonth equality is only achieved when the same dates were used to create those objects. I would expect that two yearmonths are equal when they represent the same month and not rely on some underlying data representation.

See the example below - I would expect that x and y are equal.

library(tsibble)
library(testthat)
x <- yearmonth("2020-01-01")
y <- yearmonth("2020-01-02")

x == y
#> [1] FALSE
expect_equal(x, y)
#> Error: `x` not equal to `y`.
#> Mean relative difference: 5.475851e-05

Created on 2020-10-09 by the reprex package (v0.3.0) tsibble_0.9.3 - dev version from Github.