-
Notifications
You must be signed in to change notification settings - Fork 292
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
pkg/time: support conversion of time to unix #319
Comments
Original reply by @antong in cuelang/cue#319 (comment) I was looking for a way to write constraints on time fields, such as to require a field to be within a certain time range. I think having a function to convert to UNIX time would help. When you say "add dates, etc.", do you mean expose functions for time arithmetic like the Go time.Sub(), Add(), AddDate() and so on? I think that would be useful. And being able to convert to UNIX time would allow to do this with the durations that can already be parsed and validated by the time package. About time constraints, If I understand correctly the time values as handled by the time package are actually RFC3339Nano formatted strings. (If this is so, we should probably document it. I didn't see it explicitly stated in the package doc.) As the doc says, RFC3339Nano doesn't necessarily sort correctly, so I feel a bit uneasy about that. But I guess it can only sort incorrectly between values that fall within the same second. |
I would like to work on this. I propose the following usage:
If you agree, let me know, and I can start working on this. |
Originally opened by @rogpeppe in cuelang/cue#319
Currently we can convert from unix seconds to RFC3339 but not vice-versa.
It would also be nice to be able to add dates, etc.
The text was updated successfully, but these errors were encountered: