bitwalker / timex

A complete date/time library for Elixir projects.

Home Page:https://hexdocs.pm/timex

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`Timex.from_now` unexpected result

LostKobrakai opened this issue · comments

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

  • What are the expected results?
    All of those results seem to be off by 1 day by my understanding.

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.

  • If you are certain this is a bug in Timex, do you have references I
    can use to check the algorithm/logic against? For instance, a well-established
    date/time library in another language, a paper, test suite, etc. It is by no
    means a requirement, but is immensely helpful in fixing bugs, and provides me
    extra data to use when building out the test suite