These forums have been archived and are now read-only.

The new forums are live and can be found at https://forums.eveonline.com/

Issues, Workarounds & Localization

 
  • Topic is locked indefinitely.
 

CREST & XML Server time formats incompatible with stock Go

Author
croakroach
24th Imperial Crusade
Amarr Empire
#1 - 2016-08-27 03:41:48 UTC
This has been bugging me for a while. Go only accepts standard time formats (listed here) and is not as loose as other languages. It appears that the time format used by CREST in the JSON output does not meet any of these standards and fails to decode.

Is there a simple way to resolve this without breaking every other client? I am using a workaround presently.

The code below fails with
Quote:
parsing time ""2010-11-04T13:11:00"" as ""2006-01-02T15:04:05Z07:00"": cannot parse """ as "Z07:00"




package main

import (
    "encoding/json"
    "fmt"
    "net/http"
    "time"
)

type AllianceV1 struct {
    StartDate         time.Time
    CorporationsCount int64
    Description       string
    URL               string
    ID                int64
    Name              string
    ShortName         string
    Deleted           bool
}

func main() {
    response, err := http.Get("https://crest-tq.eveonline.com/alliances/99000006/")

    if err != nil {
        fmt.Printf("%+v\n", err.Error())
        return
    }

    u := AllianceV1{}
    err = json.NewDecoder(response.Body).Decode(&u)
    if err != nil {
        fmt.Printf("%+v\n", err.Error())
        return
    }
    fmt.Printf("%+v\n", u)
}
croakroach
24th Imperial Crusade
Amarr Empire
#2 - 2016-08-31 02:47:12 UTC
Just found out the the killmail JSON through CREST is different also. So far there are three different formats and none match the standard.

Killmails:    2016.08.29 19:09:18
Most of CREST:    2006-01-02T15:04:05
XML API:    2006-01-02 15:04:05

ISO 8601:    2006-01-02T15:04:05Z


Example Killmail
Jack Tronic
borkedLabs
#3 - 2016-09-06 02:59:28 UTC  |  Edited by: Jack Tronic
http://stackoverflow.com/questions/25087960/json-unmarshal-time-that-isnt-in-rfc-3339-format


Perfectly normal to need custom logic. Heck, even C# has trouble with ISO8601 strings and sometimes needs nudging.