mirror of
https://github.com/imjasonh/go-marvel
synced 2026-07-18 14:56:37 +00:00
parse modified dates
This commit is contained in:
parent
c7ebbbc6fd
commit
22634eca6c
2 changed files with 14 additions and 1 deletions
14
marvel.go
14
marvel.go
|
|
@ -103,6 +103,18 @@ func (i Image) URL(v Variant) string {
|
|||
return fmt.Sprintf("%s/%s.%s", i.Path, string(v), i.Extension)
|
||||
}
|
||||
|
||||
type Date string
|
||||
|
||||
const dateLayout = "2006-01-02T15:04:05-0700"
|
||||
|
||||
func (d Date) Parse() time.Time {
|
||||
t, err := time.Parse(dateLayout, string(d))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
||||
func (c Client) Series(id int64, req CommonRequest) (resp struct {
|
||||
commonResponse
|
||||
Data struct {
|
||||
|
|
@ -119,7 +131,7 @@ func (c Client) Series(id int64, req CommonRequest) (resp struct {
|
|||
StartYear int
|
||||
EndYear int
|
||||
Rating string
|
||||
//Modified Date
|
||||
Modified Date
|
||||
Thumbnail Image
|
||||
Comics struct {
|
||||
Available int
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ func TestRequest(t *testing.T) {
|
|||
return
|
||||
}
|
||||
for _, iss := range r.Data.Results {
|
||||
t.Logf(iss.Modified.Parse().String())
|
||||
t.Logf(iss.Thumbnail.URL(PortraitIncredible))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue