kipcole9 / tempo

Date/Time library for Elixir based upon intervals not instants
Other
176 stars 5 forks source link

[idea] time range #9

Open dkuku opened 2 years ago

dkuku commented 2 years ago

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

kipcole9 commented 2 years ago

@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!

dkuku commented 2 years ago

~T[11:00:00]..~T[11:20:00]//"5s" is valid syntax

On Wed, 7 Sept 2022, 21:03 Kip Cole, @.***> wrote:

Closed #9 https://github.com/kipcole9/tempo/issues/9 as completed.

— Reply to this email directly, view it on GitHub https://github.com/kipcole9/tempo/issues/9#event-7341798417, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG4X42TUNQ272I23QQWDJ3V5DYJDANCNFSM6AAAAAAQGP5C6M . You are receiving this because you were mentioned.Message ID: @.***>

kipcole9 commented 2 years ago

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
 ]}
kipcole9 commented 2 years ago

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.

dkuku commented 2 years ago

No worries. It just came to my mind when you wrote about iterating the intervals so I wanted to share the idea.

On Wed, 7 Sept 2022, 21:20 Kip Cole, @.***> wrote:

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.

— Reply to this email directly, view it on GitHub https://github.com/kipcole9/tempo/issues/9#issuecomment-1239831222, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG4X4Y5LN3CKJCW7IN6KPDV5D2ITANCNFSM6AAAAAAQGP5C6M . You are receiving this because you were mentioned.Message ID: @.***>