Proposal: Introduce DateTime/NaiveDateTime.beginning_of_day and DateTime/NaiveDateTime.end_of_day

39 views
Skip to first unread message

thia.md...@gmail.com

unread,
Mar 2, 2023, 3:26:40 PM3/2/23
to elixir-lang-core
Hello, we have Date.beginning_of_month and Date.end_of_month and similar functions.
Would be nice to have other similar helpers to deal with date and datetime.

iex> DateTime.beginning_of_day(~U[2018-11-15 10:00:00Z])
~U[2018-11-15 00:00:00Z]
iex> NaiveDateTime.beginning_of_day(~N[2000-01-01 23:00:07])
~U[2000-01-01 00:00:00]
iex> DateTime.end_of_day(~U[2018-11-15 10:00:00Z])
~U[2018-11-15 23:59:59Z]
iex> NaiveDateTime.end_of_day(~N[2000-01-01 23:00:07])
~U[2000-01-01 23:59:59]

There are concerns on the compatibility of these functions between different calendars?

What do you think?

José Valim

unread,
Mar 2, 2023, 3:35:27 PM3/2/23
to elixir-l...@googlegroups.com
We can add those but those computations would need to be done by the calendars. We can definitely start with beginning of day and end of day. PRs welcome!

--
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/3d16c9e2-fda9-46c7-8c76-32a41b14eff4n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages