Date.shift implementation

30 views
Skip to first unread message

gpopides

unread,
Oct 22, 2023, 4:39:51 AM10/22/23
to elixir-lang-core
Based on Jose's comment in this post

> but I would be 90% as a happy if we had Date.shift(date, months: 1, days: 10) in Elixir (PRs are welcome, I consider this to be the last calendar feature missing in Elixir).

I would like give it a try, would you mind explaining what's missing?

Is it adding more than days (months, years) using Date.add/2, similar to Java's LocalDate.addDays(), LocalDate.addMonths() and so on?

If yes, i would like to give it a try

José Valim

unread,
Oct 22, 2023, 6:23:04 AM10/22/23
to elixir-l...@googlegroups.com
Timex.shift is probably the best reference: https://hexdocs.pm/timex/Timex.html#shift/2

Keep in mind it has many pitfalls, especially related to timezones and multiple calendars, so it is probably necessary to draft a proposal before.

There is also a debate of which module it should be defined at, maybe even "Calendar.shift/2". Also note it is named "shift" on purpose, as temporal operations aren't really arithmetic. :)

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/a5e4404f-e77f-468f-8e8b-0c0812523f39n%40googlegroups.com.

gpopides

unread,
Oct 22, 2023, 10:32:09 AM10/22/23
to elixir-lang-core
Thanks, i will have a look on the referenece first
Reply all
Reply to author
Forward
0 new messages