mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 02:31:04 +01:00
minor
This commit is contained in:
parent
06d5e56512
commit
21fa56720f
6
x/jsonx/exampler.go
Normal file
6
x/jsonx/exampler.go
Normal file
|
@ -0,0 +1,6 @@
|
|||
package jsonx
|
||||
|
||||
// Exampler is an interface used by testing to generate examples.
|
||||
type Exampler interface {
|
||||
ListExamples() []string
|
||||
}
|
|
@ -42,6 +42,8 @@ const (
|
|||
// ISO8601 describes a time compatible with javascript time format.
|
||||
type ISO8601 time.Time
|
||||
|
||||
var _ Exampler = (*ISO8601)(nil)
|
||||
|
||||
// ParseISO8601 reads from "s" and returns the ISO8601 time.
|
||||
func ParseISO8601(s string) (ISO8601, error) {
|
||||
if s == "" || s == "null" {
|
||||
|
@ -113,6 +115,16 @@ func (t ISO8601) MarshalJSON() ([]byte, error) {
|
|||
return nullLiteral, nil // Note: if the front-end wants an empty string instead I must change that.
|
||||
}
|
||||
|
||||
// Examples returns a list of example values.
|
||||
func (t ISO8601) ListExamples() []string {
|
||||
return []string{
|
||||
"2006-01-02T15:04:05",
|
||||
"2022-08-09T00:00:00.000000",
|
||||
"2022-08-10T03:21:00.000000+03:00",
|
||||
"2023-02-04T09:48:14+00:00",
|
||||
}
|
||||
}
|
||||
|
||||
// ToTime returns the unwrapped *t to time.Time.
|
||||
func (t *ISO8601) ToTime() time.Time {
|
||||
tt := time.Time(*t)
|
||||
|
|
Loading…
Reference in New Issue
Block a user