Skip to content

Commit 21fa567

Browse files
committed
minor
1 parent 06d5e56 commit 21fa567

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

x/jsonx/exampler.go

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package jsonx
2+
3+
// Exampler is an interface used by testing to generate examples.
4+
type Exampler interface {
5+
ListExamples() []string
6+
}

x/jsonx/iso8601.go

+12
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ const (
4242
// ISO8601 describes a time compatible with javascript time format.
4343
type ISO8601 time.Time
4444

45+
var _ Exampler = (*ISO8601)(nil)
46+
4547
// ParseISO8601 reads from "s" and returns the ISO8601 time.
4648
func ParseISO8601(s string) (ISO8601, error) {
4749
if s == "" || s == "null" {
@@ -113,6 +115,16 @@ func (t ISO8601) MarshalJSON() ([]byte, error) {
113115
return nullLiteral, nil // Note: if the front-end wants an empty string instead I must change that.
114116
}
115117

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+
116128
// ToTime returns the unwrapped *t to time.Time.
117129
func (t *ISO8601) ToTime() time.Time {
118130
tt := time.Time(*t)

0 commit comments

Comments
 (0)