expr
expr copied to clipboard
Add duration literal support
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.
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?
Mostly for the sake of readability. I'm using durations frequently, and I find literal format more readable and quicker to type as well.