openweathermap icon indicating copy to clipboard operation
openweathermap copied to clipboard

Forecast datetime should be parsed

Open AlmogBaku opened this issue 8 years ago • 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

AlmogBaku avatar May 15 '16 13:05 AlmogBaku

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!

briandowns avatar May 15 '16 17:05 briandowns