1
0
Fork 0
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:
Jason Hall 2014-04-26 00:12:17 -04:00
parent c7ebbbc6fd
commit 22634eca6c
2 changed files with 14 additions and 1 deletions

View file

@ -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

View file

@ -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))
}
}