Documentation ¶
Overview ¶
Package iso6801 contains a custom time type which (de)serializes in ISO8601 format.
Index ¶
Examples ¶
Constants ¶
View Source
const Layout = "2006-01-02T15:04:05.999Z"
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 Parse ¶ added in v1.1.0
Parse a string into an ISO8601 time. Returns an error if the string is not in ISO8601 format.
func (Time) MarshalDynamoDBAttributeValue ¶ added in v1.1.1
func (ct Time) MarshalDynamoDBAttributeValue() (types.AttributeValue, error)
MarshalDynamoDBAttributeValue converts a custom type to a DynamoDB attribute value.
func (Time) MarshalJSON ¶
MarshalJSON writes a quoted string in the custom format
func (*Time) UnmarshalDynamoDBAttributeValue ¶ added in v1.1.1
func (ct *Time) UnmarshalDynamoDBAttributeValue(av types.AttributeValue) error
UnmarshalDynamoDBAttributeValue converts a DynamoDB attribute value to a custom type.
func (*Time) UnmarshalJSON ¶
UnmarshalJSON Parses the json string in the custom format
Click to show internal directories.
Click to hide internal directories.