briandowns/openweathermap

Forecast datetime should be parsed

AlmogBaku opened this issue · 1 comments

JsonUnixTime helper for that matter:

type JsonUnixTime time.Time
func (t JsonUnixTime) MarshalJSON() ([]byte, error) {
    return strconv.AppendInt(nil, time.Time(t).Unix(), 10), nil
}
func (t *JsonUnixTime) UnmarshalJSON(data []byte) (err error) {
    // Fractional seconds are handled implicitly by Parse.
    unixTime, err := strconv.ParseInt(string(data), 10, 64)
    *t = JsonUnixTime(time.Unix(unixTime, 0))
    return nil
}

Will work on a PR later

This is great since I've been meaning to do this however haven't had time. This should be done cross package. Can you make your solution take that into consideration for other calls thanks again!