File tree 2 files changed +18
-0
lines changed
2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change
1
+ package jsonx
2
+
3
+ // Exampler is an interface used by testing to generate examples.
4
+ type Exampler interface {
5
+ ListExamples () []string
6
+ }
Original file line number Diff line number Diff line change @@ -42,6 +42,8 @@ const (
42
42
// ISO8601 describes a time compatible with javascript time format.
43
43
type ISO8601 time.Time
44
44
45
+ var _ Exampler = (* ISO8601 )(nil )
46
+
45
47
// ParseISO8601 reads from "s" and returns the ISO8601 time.
46
48
func ParseISO8601 (s string ) (ISO8601 , error ) {
47
49
if s == "" || s == "null" {
@@ -113,6 +115,16 @@ func (t ISO8601) MarshalJSON() ([]byte, error) {
113
115
return nullLiteral , nil // Note: if the front-end wants an empty string instead I must change that.
114
116
}
115
117
118
+ // Examples returns a list of example values.
119
+ func (t ISO8601 ) ListExamples () []string {
120
+ return []string {
121
+ "2006-01-02T15:04:05" ,
122
+ "2022-08-09T00:00:00.000000" ,
123
+ "2022-08-10T03:21:00.000000+03:00" ,
124
+ "2023-02-04T09:48:14+00:00" ,
125
+ }
126
+ }
127
+
116
128
// ToTime returns the unwrapped *t to time.Time.
117
129
func (t * ISO8601 ) ToTime () time.Time {
118
130
tt := time .Time (* t )
You can’t perform that action at this time.
0 commit comments