4 ms·
Reminds me of the Ruby library chronic https://github.com/mojombo/chronic https://github.com/mojombo/chronic It's pretty good at natural language interpretatio
by jfax 5y ago
Reminds me of the Ruby library chronic https://github.com/mojombo/chronic https://github.com/mojombo/chronic
It's pretty good at natural language interpretation of dates, and the basic "from today" calculations, but cool to also see here natural expressions to parse between dates.
- Toutouxc 5y agoAlso plain old ActiveSupport. It doesn't have the natural language goodies, but it has all kinds of handily named methods, e.g. you can write (functional folks may want to look away) 3.weeks.ago.next_month.beginning_of_month.last_weekday.end_of_day and it resolves to 2021-10-29 23:59:59.9999 as of today.
- pmontra 5y agoFunctional folks could write that in Elixir as {:ok, end_of_november} = 3 ¦> weeks ¦> ago ¦> next_month ¦> beginning_of_month ¦> last_weekday ¦> end_of_day given the appropriate function declarations accepting at least either a number or a DateTime or some intermediate data structure as argument.