Skip to content

Commit

Permalink
Merge pull request #86 from mailgun/cclark/dev
Browse files Browse the repository at this point in the history
PIP-1359: add StringWithOffset method to RFC822Time struct
  • Loading branch information
Takumi2008 authored Jul 29, 2021
2 parents 73d8fb2 + db98171 commit 4efdeb2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions clock/rfc822.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,7 @@ func (t *RFC822Time) UnmarshalJSON(s []byte) error {
func (t RFC822Time) String() string {
return t.Format(RFC1123)
}

func (t RFC822Time) StringWithOffset() string {
return t.Format(RFC1123Z)
}
7 changes: 7 additions & 0 deletions clock/rfc822_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"testing"
"time"

"github.com/stretchr/testify/assert"
)
Expand Down Expand Up @@ -162,3 +163,9 @@ func TestParseRFC822Time(t *testing.T) {
})
}
}

func TestStringWithOffset(t *testing.T) {
now := time.Now().UTC()
r := NewRFC822Time(now)
assert.Equal(t, now.Format(time.RFC1123Z), r.StringWithOffset())
}

0 comments on commit 4efdeb2

Please sign in to comment.