-
Notifications
You must be signed in to change notification settings - Fork 2
Add time functions to convert RFC3999 timestamps to Unix format and vice versa #57
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
base: master
Are you sure you want to change the base?
Conversation
|
PR is now waiting for a maintainer to take action. Note for the maintainer: Commands available:
|
|
PR is now waiting for a maintainer to take action. Note for the maintainer: Commands available:
|
| "github.com/pulumi/pulumi-go-provider/infer" | ||
| ) | ||
|
|
||
| type Rfc3339tounix struct{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| type Rfc3339tounix struct{} | |
| type Rfc3339ToUnix struct{} |
CamelCase all the names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other functions are also using the sentence case like
pulumi-std/std/base64decode.go
Line 26 in 4e9e486
| type Base64decode struct{} |
Line 24 in 4e9e486
| type Cidrnetmask struct{} |
pulumi-std/std/filebase64sha256.go
Line 22 in 4e9e486
| type Filebase64sha256 struct{} |
and others, hence I used that casing here. I also tried naming RFC3999ToUnix and that resulted in some tokens being rfC3999ToUnix which is weird.
|
PR is now waiting for a maintainer to take action. Note for the maintainer: Commands available:
|
|
@Frassle , I am in a bit of a dilemma regarding the seconds precision that I should allow in these functions. RFC3999 allows fractional seconds but Unix time itself is seconds precision. It is possible to have millisecond, microsecond or nanosecond precision Unix time but that means I will have to ensure that the user inputs the precision I am asking, even adding 0's at the end if their unix time is only in seconds. I am torn between allowing more than seconds precision as a lot of systems support millisecond unix time and I have seen a lot of RFC3999 times with millisecond fractions. But then, why stick at millisecond when modern systems can handle up to nanoseconds. I fact, I can see even more issues. Imagine my functions only allow nanoseconds as UNIX input and output. If another resource outputs or needs an input of the time in milliseconds, I will need to do a math conversion, which I don't know if its possible in YAML. Even if it's possible, it creates a dangerous point of failure as if the other resource suddenly changes its schema to seconds instead of milliseconds, my mathematical operation can point to a totally different instance in time. Or I can just keep things to spec and only handle unix seconds... |
This PR has been moved here from pulumi/pulumi-yaml#576 based on the discussion on this comment.
OP:
Some providers outputs unix timestamps and some other RFC 3339 where some providers input unix and others RFC 3339 and I need to convert between the 2 formats when passing outputs to inputs. I am using YAML only as I want to keep using declarative syntax. Hence, based on the discussion I had in the community slack (ref: https://pulumi-community.slack.com/archives/C037PV12W6L/p1715335945150989) with @t0yv0 .
Please note that for now, I have only implemented one of the 2 functions I want to implement to check with you folks if I am going in the right direction.I have implemented both the functions.