I think larger units were added since 1.14, but if you cannot upgrade for some 
reason, Timex has a nice API: `Timex.shift(dt, months: 1, days: 4.5, minutes: 
-30, seconds: 50)`

Sent from Proton Mail mobile

-------- Original Message --------
On 12 Dec 2022, 20:21, Daniel Kukuła wrote:

> Hi - this bothers me because every time when I wan't to add longer period of 
> time I need to manually calculate the number instead of use something built 
> in or use erlang.
>
> `DateTime.add(DateTime.utc_now(), :timer.hours(-30 * 24), :millisecond)` .
>
> Erlang has up to 1hour shortcut functions - but 1day still is 24h and 
> everytime let's say we wan't to expire some old data from database then 
> DateTime.add(-30, :days) is still plenty good for most of the cases.
> In python timedelta you can specify also weeks:
> ```
> from datetime import timedeltadelta = timedelta( days=50, seconds=27, 
> microseconds=10, milliseconds=29000, minutes=5, hours=8, weeks=2)
> ```
>
> --
> 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-core+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> [https://groups.google.com/d/msgid/elixir-lang-core/b3abc7f0-7989-42f5-a087-3443155f69d6n%40googlegroups.com](https://groups.google.com/d/msgid/elixir-lang-core/b3abc7f0-7989-42f5-a087-3443155f69d6n%40googlegroups.com?utm_medium=email&utm_source=footer).

-- 
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-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/IaVAEQACh7Kx8HGIff3olnMgJIcHTM3pToJyhWTXrR8eS5mR8yMwaTTEmLjbAKL_L37pLUFMzXCEBz74bszMqePN20UWB7oKLqye3jCP4cs%3D%40pm.me.

Reply via email to