bitwalker / timex

A complete date/time library for Elixir projects.
https://hexdocs.pm/timex
MIT License
1.75k stars 374 forks source link

`Timex.from_now` unexpected result #720

Open LostKobrakai opened 2 years ago

LostKobrakai commented 2 years ago

Steps to reproduce

timex 3.7.8

{:ok, dt, 0} = DateTime.from_iso8601("2022-07-30 17:06:27Z")
{DateTime.utc_now(), Timex.from_now(dt)}
# {~U[2022-08-01 08:20:03.093411Z], "yesterday"}

{:ok, dt, 0} = DateTime.from_iso8601("2022-07-29 17:17:39Z")
{DateTime.utc_now(), Timex.from_now(dt)}
# {~U[2022-08-01 08:21:43.460553Z], "2 days ago"}

Description of issue

Yesterday is the day before today, which from the perspective of 2022-08-01 is 2022-07-31, not 2022-07-30. Also in the same context I'd consider 2022-07-29 to be 3 days ago, though that one feels a bit more open to interpretation.