File: gen.txtar

package info (click to toggle)
golang-github-cue-lang-cue 0.14.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,644 kB
  • sloc: makefile: 20; sh: 15
file content (52 lines) | stat: -rw-r--r-- 1,364 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# generated from the original tests.
# Henceforth it may be nicer to group tests into separate files.
-- in.cue --
import "time"

t1: time.Time & "1937-01-01T12:00:27.87+00:20"
t2: time.Time & "no time"
t3: time.Unix(1500000000, 123456)

parse: {
	t1: time.Parse(time.RFC822, "01 Jul 21 17:54 CEST")
	t1: time.Parse(time.RFC822, "01 Jul 21 17:54 CDST")
	t1: time.Parse(time.RFC822, "01 Jul 21 17:54 PST")
	t1: time.Parse(time.RFC822, "01 Jul 21 17:54 PDT")
	t1: time.Parse(time.RFC822, "01 Jul 21 17:54 EST")
	t1: time.Parse(time.RFC822, "01 Jul 21 17:54 EDT")

	t2: time.Parse(time.RFC3339Date, "2021-02-19")

	_layout: "01/02 03:04:05PM '06 -0700"
	t3:      time.Parse(_layout, _layout)
}

split: {
	t1: time.Split("2017-07-14T02:40:00.000123456Z")
}
-- out/time --
Errors:
t2: invalid value "no time" (does not satisfy time.Time): error in call to time.Time: invalid time "no time":
    ./in.cue:4:5
    ./in.cue:4:17

Result:
t1: "1937-01-01T12:00:27.87+00:20"
t2: _|_ // t2: invalid value "no time" (does not satisfy time.Time): t2: error in call to time.Time: invalid time "no time"
t3: "2017-07-14T02:40:00.000123456Z"
parse: {
	t1: "2021-07-01T17:54:00Z"
	t2: "2021-02-19T00:00:00Z"
	t3: "2006-01-02T22:04:05Z"
}
split: {
	t1: {
		year:       2017
		month:      7
		day:        14
		hour:       2
		minute:     40
		second:     0
		nanosecond: 123456
	}
}