[idea] time range
dkuku opened this issue · 5 comments
This idea came to my mind when I read your blog post to have a possibility to represent time as a range-like structure:
11:00..11:20//5s
@dkuku thanks for the suggestion, I like it! Unfortunately its not valid Elixir syntax:
iex(1)> 11:00..11:20//5s
** (SyntaxError) iex:1:3: unexpected token: ":" (column 3, code point U+003A)
|
1 | 11:00..11:20//5s
| ^
(iex 1.14.0) lib/iex/evaluator.ex:292: IEx.Evaluator.parse_eval_inspect/3
(iex 1.14.0) lib/iex/evaluator.ex:187: IEx.Evaluator.loop/1
(iex 1.14.0) lib/iex/evaluator.ex:32: IEx.Evaluator.init/4
(stdlib 4.0) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
Which means its not really implementable. There's not doubt that ISO8601 syntax isn't always great on the human readable front so I hope that people might interested in layering free text time expressions or perhaps other interpretations on top.
Closing for now as "can't do" but I appreciate the suggestion - keep them coming!
Oh that's interesting! Similarly:
iex> quote do
...> ~o"11:00"..~o"12:00"//2
...> end
{:..//, [context: Elixir, imports: [{3, Kernel}]],
[
{:sigil_o, [delimiter: "\"", context: Elixir, imports: [{2, Tempo.Sigil}]],
[{:<<>>, [], ["11:00"]}, []]},
{:sigil_o, [delimiter: "\"", context: Elixir, imports: [{2, Tempo.Sigil}]],
[{:<<>>, [], ["12:00"]}, []]},
2
]}
As you can imagine, the "todo" list for Tempo is long so while I think this is interesting and I'll definitely explore further, I need to complete math, comparisons and selections first. Thanks for following up - I'll leave the issue open as a reminder.