Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add time.weekday built-in function #789

Closed
tsandall opened this issue Jun 18, 2018 · 0 comments
Closed

Add time.weekday built-in function #789

tsandall opened this issue Jun 18, 2018 · 0 comments

Comments

@tsandall
Copy link
Member

tsandall commented Jun 18, 2018

We currently have built-in functions to convert nanoseconds to year, month, day and hour, minute second (time.date and time.clock respectively.) In some cases, it makes sense to express policies in terms of days of the week. To support this, OPA should include a time.weekday built-in function that takes nanoseconds since epoch and returns the day of the week.

For example:

> time.weekday(time.now_ns())
"Monday"

Add built-in functions is relatively straightforward. Here's an example: db34907.

It should be possible to just convert nanoseconds into a time.Time struct in Go and then call time.Time#Weekday to get the day of the week.

This code can into topdown/time.go

srenatus added a commit to srenatus/opa that referenced this issue Jun 25, 2018
Fixes open-policy-agent#789.

Signed-off-by: Stephan Renatus <[email protected]>
tsandall pushed a commit that referenced this issue Jun 25, 2018
Fixes #789.

Signed-off-by: Stephan Renatus <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant