diff --git a/CHANGELOG.md b/CHANGELOG.md index c1b0057e..004cfadf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Updated tzdata to fix issues with 2024b - Fix deprecation: Module.eval_quoted/4 is deprecated. Use Code.eval_quoted/3 instead - Fix deprecation: "min..max inside match is deprecated" +- Fix deprecation: default arguments in protocol definitions are deprecated in Elixir 1.20 (`Timex.Comparable.compare/3`, `Timex.Comparable.diff/3`, `Timex.Protocol.to_datetime/2`) --- diff --git a/lib/comparable/comparable.ex b/lib/comparable/comparable.ex index 307ca271..82ba2627 100644 --- a/lib/comparable/comparable.ex +++ b/lib/comparable/comparable.ex @@ -81,7 +81,7 @@ defprotocol Timex.Comparable do 0 """ @spec compare(comparable, comparable, granularity) :: compare_result - def compare(a, b, granularity \\ :microsecond) + def compare(a, b, granularity) @doc """ Get the difference between two date or datetime types. @@ -136,5 +136,5 @@ defprotocol Timex.Comparable do 0 """ @spec diff(comparable, comparable, granularity) :: diff_result - def diff(a, b, granularity \\ :microsecond) + def diff(a, b, granularity) end diff --git a/lib/protocol.ex b/lib/protocol.ex index 6d387309..1a6249ac 100644 --- a/lib/protocol.ex +++ b/lib/protocol.ex @@ -42,10 +42,9 @@ defprotocol Timex.Protocol do Convert a date/time value to a DateTime. An optional timezone can be provided, UTC will be assumed if one is not provided. """ - @spec to_datetime(Types.valid_datetime()) :: DateTime.t() | {:error, term} @spec to_datetime(Types.valid_datetime(), Types.valid_timezone()) :: DateTime.t() | Timex.AmbiguousDateTime.t() | {:error, term} - def to_datetime(datetime, timezone \\ :utc) + def to_datetime(datetime, timezone) @doc """ Convert a date/time value to a NaiveDateTime diff --git a/lib/timex.ex b/lib/timex.ex index 8c7c8ea9..b21ac815 100644 --- a/lib/timex.ex +++ b/lib/timex.ex @@ -1021,7 +1021,7 @@ defmodule Timex do compare(a, b, :microseconds) end - defdelegate compare(a, b), to: Timex.Comparable + def compare(a, b), do: Timex.Comparable.compare(a, b, :microsecond) @doc """ Compare two `Timex.Comparable` values, returning one of the following values: @@ -1090,7 +1090,7 @@ defmodule Timex do @spec diff(Time.t() | Comparable.comparable(), Time.t() | Comparable.comparable()) :: Duration.t() | integer | {:error, term} def diff(%Time{} = a, %Time{} = b), do: diff(a, b, :microseconds) - defdelegate diff(a, b), to: Timex.Comparable + def diff(a, b), do: Timex.Comparable.diff(a, b, :microsecond) @doc """ Calculate time interval between two dates. The result will be a signed integer, negative