Skip to content

time-related helpers #33

Description

@srenatus

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions