Skip to content

Commit

Permalink
Merge pull request #64 from mailgun/maxim/develop
Browse files Browse the repository at this point in the history
PIP-774: Allow single digit day in RFC822 time
  • Loading branch information
horkhe authored Apr 14, 2020
2 parents 2296d2f + e215f86 commit ab6a919
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions v3/clock/rfc822.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ func (t *RFC822Time) UnmarshalJSON(s []byte) error {
if err != nil {
return err
}
if t.Time, err = Parse(RFC1123, q); err == nil {
if t.Time, err = Parse("Mon, 2 Jan 2006 15:04:05 MST", q); err == nil {
return nil
}
if err, ok := err.(*ParseError); !ok || err.LayoutElem != "MST" {
return err
}
if t.Time, err = Parse(RFC1123Z, q); err != nil {
if t.Time, err = Parse("Mon, 2 Jan 2006 15:04:05 -0700", q); err != nil {
return err
}
return nil
Expand Down
12 changes: 12 additions & 0 deletions v3/clock/rfc822_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ func TestRFC822Unmarshaling(t *testing.T) {
inRFC822: "Thu, 29 Aug 2019 11:20:07 +0330",
outRFC3339: "2019-08-29T11:20:07+03:30",
outRFC822: "Thu, 29 Aug 2019 11:20:07 +0330",
}, {
inRFC822: "Sun, 01 Sep 2019 11:20:07 +0300",
outRFC3339: "2019-09-01T11:20:07+03:00",
outRFC822: "Sun, 01 Sep 2019 11:20:07 MSK",
}, {
inRFC822: "Sun, 1 Sep 2019 11:20:07 +0300",
outRFC3339: "2019-09-01T11:20:07+03:00",
outRFC822: "Sun, 01 Sep 2019 11:20:07 MSK",
}, {
inRFC822: "Sun, 1 Sep 2019 11:20:07 +0300",
outRFC3339: "2019-09-01T11:20:07+03:00",
outRFC822: "Sun, 01 Sep 2019 11:20:07 MSK",
}} {
tcDesc := fmt.Sprintf("Test case #%d: %v", i, tc)
var ts testStruct
Expand Down

0 comments on commit ab6a919

Please sign in to comment.