-
Notifications
You must be signed in to change notification settings - Fork 37
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
Improve Date/DateTime interactions #62
Conversation
This PR includes some improvements when we interact with `Date` or `DateTime`. * Elixir v1.15 introduced `{Date,DateTime,NaiveDateTime,Time}.{after?/2,before?/2}`. This means that we could improve the readability on some Date/Time comparisons. * I also took the chance to transform some `Timex` `defdelegate` to their native equivalent. Finally, most of these additions only apply if we're running on Elixir v1.15, that's why I decided to add new entries for Elixir and OTP matrix for CI purposes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mind nixing the Timex compare bits and just leaving the 1.15 changes?
after thinking on it for a bit, i'm down with getting rid of Timex.now and Timex.today in favor of their explicit versions 👍
defp style({{:., dm, [{:__aliases__, am, [:Timex]}, :today]}, funm, args}), | ||
do: {{:., dm, [{:__aliases__, am, [:Date]}, :utc_today]}, funm, args} | ||
|
||
defp style({{:., dm, [{:__aliases__, am, [:Timex]}, :now]}, funm, args}), | ||
do: {{:., dm, [{:__aliases__, am, [:DateTime]}, :utc_now]}, funm, args} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let me sit on these ones -- i'd considered doing the same earlier, but nixed it as too specific to adbe internals 🤔 still, this repo is all about forcing our views on others xD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is great, ty milton!
This PR includes some improvements when interacting with
Date
orDateTime
.{Date,DateTime,NaiveDateTime,Time}.{after?/2,before?/2}
. This means that we could improve the readability of some Date/Time comparisons.Timex
defdelegate
to their native equivalent.Finally, most of these additions only apply if we're running on Elixir v1.15, so I added new entries for Elixir and OTP matrix for CI purposes.