Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions rest/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,12 @@ type Date struct {

// UnmarshalJSON parses datetime strings returned by the transip api
func (tt *Time) UnmarshalJSON(input []byte) error {
loc, err := time.LoadLocation("Europe/Amsterdam")
if err != nil {
return err
}
// don't parse on empty dates
if string(input) == `""` {
return nil
}

loc := time.FixedZone("CEST", 2*60*60)
newTime, err := time.ParseInLocation(`"2006-01-02 15:04:05"`, string(input), loc)
if err != nil {
return err
Expand All @@ -62,14 +60,12 @@ func (tt *Time) UnmarshalJSON(input []byte) error {

// UnmarshalJSON parses date strings returned by the transip api
func (td *Date) UnmarshalJSON(input []byte) error {
loc, err := time.LoadLocation("Europe/Amsterdam")
if err != nil {
return err
}
// don't parse on empty dates
if string(input) == `""` {
return nil
}

loc := time.FixedZone("CEST", 2*60*60)
newTime, err := time.ParseInLocation(`"2006-01-02"`, string(input), loc)
if err != nil {
return err
Expand Down