Documentation ¶
Overview ¶
Package iso6801 contains a custom time type which (de)serializes in ISO8601 format.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Time ¶
Example ¶
package main import ( "encoding/json" "fmt" "time" "github.com/common-fate/iso8601" ) func main() { type MyStruct struct { CreatedAt iso8601.Time `json:"createdAt"` } s := MyStruct{ CreatedAt: iso8601.New(time.Date(2000, 01, 01, 10, 0, 0, 0, time.UTC)), } str, _ := json.Marshal(s) fmt.Printf("%s", str) }
Output: {"createdAt":"2000-01-01T10:00:00Z"}
func (Time) MarshalJSON ¶
MarshalJSON writes a quoted string in the custom format
func (*Time) UnmarshalJSON ¶
UnmarshalJSON Parses the json string in the custom format
Click to show internal directories.
Click to hide internal directories.