Documentation ¶
Overview ¶
Package extratime is an extra package for unmarshalling and marshalling time format to json and xml.
Example ¶
package main import ( "encoding/json" "encoding/xml" "fmt" "github.com/johejo/extratime" ) type A struct { XMLName xml.Name `xml:"a"` Text string `xml:",chardata"` B extratime.RFC1123 `xml:"b"` } func main() { // xml const x = "<a><b>Mon, 02 Jan 2006 15:04:05 MST</b></a>" var a A if err := xml.Unmarshal([]byte(x), &a); err != nil { panic(err) } xb, err := xml.Marshal(a) if err != nil { panic(err) } fmt.Println(string(xb)) // json const j = `{"t": "Mon, 02 Jan 2006 15:04:05 MST"}` var m map[string]extratime.RFC1123 if err := json.Unmarshal([]byte(j), &m); err != nil { panic(err) } jb, err := json.Marshal(m) if err != nil { panic(err) } fmt.Println(string(jb)) }
Output: <a><b>Mon, 02 Jan 2006 15:04:05 MST</b></a> {"t":"Mon, 02 Jan 2006 15:04:05 MST"}
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ANSIC ¶
func (ANSIC) MarshalJSON ¶
func (ANSIC) MarshalXML ¶
func (*ANSIC) UnmarshalJSON ¶
func (*ANSIC) UnmarshalXML ¶
type Kitchen ¶
func (Kitchen) MarshalJSON ¶
func (Kitchen) MarshalXML ¶
func (*Kitchen) UnmarshalJSON ¶
func (*Kitchen) UnmarshalXML ¶
type RFC1123 ¶
func (RFC1123) MarshalJSON ¶
func (RFC1123) MarshalXML ¶
func (*RFC1123) UnmarshalJSON ¶
func (*RFC1123) UnmarshalXML ¶
type RFC1123Z ¶
func (RFC1123Z) MarshalJSON ¶
func (RFC1123Z) MarshalXML ¶
func (*RFC1123Z) UnmarshalJSON ¶
func (*RFC1123Z) UnmarshalXML ¶
type RFC822 ¶
func (RFC822) MarshalJSON ¶
func (RFC822) MarshalXML ¶
func (*RFC822) UnmarshalJSON ¶
func (*RFC822) UnmarshalXML ¶
type RFC822Z ¶
func (RFC822Z) MarshalJSON ¶
func (RFC822Z) MarshalXML ¶
func (*RFC822Z) UnmarshalJSON ¶
func (*RFC822Z) UnmarshalXML ¶
type RFC850 ¶
func (RFC850) MarshalJSON ¶
func (RFC850) MarshalXML ¶
func (*RFC850) UnmarshalJSON ¶
func (*RFC850) UnmarshalXML ¶
type RubyDate ¶
func (RubyDate) MarshalJSON ¶
func (RubyDate) MarshalXML ¶
func (*RubyDate) UnmarshalJSON ¶
func (*RubyDate) UnmarshalXML ¶
type Stamp ¶
func (Stamp) MarshalJSON ¶
func (Stamp) MarshalXML ¶
func (*Stamp) UnmarshalJSON ¶
func (*Stamp) UnmarshalXML ¶
type StampMicro ¶
func (StampMicro) MarshalJSON ¶
func (t StampMicro) MarshalJSON() ([]byte, error)
func (StampMicro) MarshalXML ¶
func (t StampMicro) MarshalXML(e *xml.Encoder, start xml.StartElement) error
func (*StampMicro) UnmarshalJSON ¶
func (t *StampMicro) UnmarshalJSON(data []byte) error
func (*StampMicro) UnmarshalXML ¶
func (t *StampMicro) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
type StampMilli ¶
func (StampMilli) MarshalJSON ¶
func (t StampMilli) MarshalJSON() ([]byte, error)
func (StampMilli) MarshalXML ¶
func (t StampMilli) MarshalXML(e *xml.Encoder, start xml.StartElement) error
func (*StampMilli) UnmarshalJSON ¶
func (t *StampMilli) UnmarshalJSON(data []byte) error
func (*StampMilli) UnmarshalXML ¶
func (t *StampMilli) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
type StampNano ¶
func (StampNano) MarshalJSON ¶
func (StampNano) MarshalXML ¶
func (*StampNano) UnmarshalJSON ¶
func (*StampNano) UnmarshalXML ¶
type UnixDate ¶
func (UnixDate) MarshalJSON ¶
func (UnixDate) MarshalXML ¶
func (*UnixDate) UnmarshalJSON ¶
func (*UnixDate) UnmarshalXML ¶
type UnixTimeStamp ¶
func (UnixTimeStamp) MarshalJSON ¶
func (u UnixTimeStamp) MarshalJSON() ([]byte, error)
func (UnixTimeStamp) MarshalXML ¶
func (u UnixTimeStamp) MarshalXML(e *xml.Encoder, start xml.StartElement) error
func (*UnixTimeStamp) UnmarshalJSON ¶
func (u *UnixTimeStamp) UnmarshalJSON(data []byte) error
func (*UnixTimeStamp) UnmarshalXML ¶
func (u *UnixTimeStamp) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
Click to show internal directories.
Click to hide internal directories.