Daniel Kukuła
unread,Dec 12, 2022, 7:21:27 AM12/12/22Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to elixir-lang-core
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 timedelta
delta = timedelta(
days=50,
seconds=27,
microseconds=10,
milliseconds=29000,
minutes=5,
hours=8,
weeks=2
)
```