expr icon indicating copy to clipboard operation
expr copied to clipboard

Add duration literal support

Open fmarcia opened this issue 2 years ago • 2 comments

This pull request adds support for duration literal:

-1h == -1 * 1h
+1h == 1h
2 * 1h == 2h
1h + 1m == 1h1m
1h - 1m == 59m
1h / 10m == 6
1h / 2 == 30m

round, max, min and abs builtin functions have been updated to support duration as well.

fmarcia avatar Dec 13 '23 21:12 fmarcia

I'm not sure yet if this should be added directly to the language itself. We already have duration() func.

Why do you think this should be implemented directly in the language?

antonmedv avatar Dec 18 '23 20:12 antonmedv

Mostly for the sake of readability. I'm using durations frequently, and I find literal format more readable and quicker to type as well.

fmarcia avatar Dec 18 '23 21:12 fmarcia