-
Notifications
You must be signed in to change notification settings - Fork 0
/
rfc822_field.go
36 lines (31 loc) · 1.02 KB
/
rfc822_field.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @ Copyright (c) Michael Leahcim @
// @ You can find additional information regarding licensing of this work in LICENSE.md @
// @ You must not remove this notice, or any other, from this software. @
// @ All rights reserved. @
// @@@@@@ At 2019-05-17 00:33 <thereisnodotcollective@gmail.com> @@@@@@@@@@@@@@@@@@@@@@@@
package emerchantpay_rss_reader
import (
"encoding/xml"
"time"
)
type rfc822 struct {
time.Time
}
func (c *rfc822) parseIntoSelf(input string) error {
const RFC822 = "Mon, 02 Jan 2006 15:04:05 -0700"
parse, err := time.Parse(RFC822, input)
if err != nil {
return err
}
*c = rfc822{parse}
return nil
}
func (c *rfc822) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
var v string
err := d.DecodeElement(&v, &start)
if err != nil {
return err
}
return c.parseIntoSelf(v)
}