Open
Description
I see no effective method for manipulating dates in CUE.
time.Parse
helps ingest strings with time values, but it also returns a string, which needs parsing to be useful.
time.Parse(layout, value string) (string, error)
time.Format
is even less useful: it can be used to create a value representing a set of all strings matching the specified layout.
func Format(value, layout string) (bool, error)
Notice that Parse and Format take arguments in different orders.
What version of CUE are you using (cue version
)?
$ cue version cue version v0.4.2 linux/amd64
Does this issue reproduce with the latest release?
Yes
What did you see?
-- in.cue -- import "time" format: time.Format("2022-01-31", time.RFC3339Date) parse: time.Parse(time.RFC3339Date, "2022-01-31") -- log -- $ cue export in.cue { "format": true, "parse": "2022-01-31T00:00:00Z" }
What did you expect to see?
-- in.cue -- import "time" format: time.Format(parse, "02/01/2006") parse: time.Parse(time.RFC3339Date, "2022-01-31") split: time.SplitParts(parse) -- log -- $ cue export in.cue { "format": "31/01/2022", "parse": "2022-01-31T00:00:00Z" "split": { "year": 2022, "month": 1, "day": 31, "hour": 0, "minute": 0, // ... } }