library icon indicating copy to clipboard operation
library copied to clipboard

time-related helpers

Open srenatus opened this issue 5 years ago • 0 comments

Repeatedly, the handling of time and date using nanoseconds has gotten people stumbling.

The situation could perhaps be improved if we had some rego-only helper methods? I'm imaging something like

days(n) = x {
  x := n * hours(24)
}

hours(n) = x {
  x := n * minutes(60)
}

minutes(n) = x {
  x := n * seconds(60)
}

seconds(n) = x {
  x := n * 1000000000
}

So that you could write time.now_ns() - time.days(1) etc.

This would be similar to how golang does it in time's constants.

srenatus avatar Dec 18 '19 13:12 srenatus