I am currently building a Phoenix app and am relatively new to the ecosystem. Having come from Ruby on Rails, I'm quite used to the convenience date/time methods available in rails (through the builtin ActiveSupport Gem I believe). For example:
1.day.ago
some_date_time + 1.hour
some_date.next_weekday.at_beginning_of_day
I especially appreciate their ability to clearly & concisely express conceptually simple (to humans at least) time operations, while abstracting away the messy date math.
I find the following objectionable
NaiveDateTime.add(
NaiveDateTime.utc_now(),
Enum.random(-5..-1) * 60 * 60 * 24)
It's not immediately clear & won't handle subtle time caveats like leap seconds/days etc. It's also not immediately clear how I might move forward 1 month or year.
Is there a popular/canon Elixir package that provides similar clarity & power? Bonus points if it's also concise.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…