Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timex diff/3 fails when working with a negative date #765

Open
IceDragon200 opened this issue Oct 2, 2024 · 0 comments
Open

Timex diff/3 fails when working with a negative date #765

IceDragon200 opened this issue Oct 2, 2024 · 0 comments

Comments

@IceDragon200
Copy link

IceDragon200 commented Oct 2, 2024

This is pretty niche, but I forgot which version of Elixir allowed dates to have negative years, I've been using it for a project of mine with great success, until I needed to use some Timex.diff/3 on it, granted I could just use Date.diff/2 in some cases, but if anything outside of days is required, well...

Steps to reproduce

Timex.diff(~D[-1755-01-01], Date.utc_today(), :years)

Description of issue

** (FunctionClauseError) no function clause matching in :calendar.last_day_of_the_month/2

    The following arguments were given to :calendar.last_day_of_the_month/2:

        # 1
        -1755

        # 2
        1

    (stdlib 6.1) calendar.erl:373: :calendar.last_day_of_the_month/2
    (stdlib 6.1) calendar.erl:222: :calendar.date_to_gregorian_days/3
    (stdlib 6.1) calendar.erl:252: :calendar.datetime_to_gregorian_seconds/1
    (timex 3.7.11) lib/date/date.ex:16: Timex.Protocol.Date.to_gregorian_microseconds/1
    (timex 3.7.11) lib/comparable/diff.ex:15: Timex.Comparable.Diff.diff/3
    iex:2: (file)

So there might be room to utilize Elixir's date/time modules in more places rather than relying on erlang's calendar, I have no idea what it would take to make this work (not that familiar with the internals of Timex)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant