diff --git a/external_coachsequence.go b/external_coachsequence.go index 811546c96e978038e0b2d29b70bfd2986306544b..d890f71b0bca870386bba677700d09b3b99b6e8a 100644 --- a/external_coachsequence.go +++ b/external_coachsequence.go @@ -95,7 +95,7 @@ type rawCoachSequenceFormation struct { Type string `json:"zuggattung"` TrainId string `json:"zugnummer"` ServiceId string `json:"serviceid"` - StartingDate BahnDate `json:"planstarttag"` + StartingDate bahnDate `json:"planstarttag"` JourneyId string `json:"fahrtid"` IsPlannedFormation bool `json:"istplaninformation"` } @@ -116,8 +116,8 @@ func parseCoachSequenceFormation(data rawCoachSequenceFormation) CoachSequenceFo } type rawCoachSequenceStop struct { - Departure MediumBahnTime `json:"abfahrtszeit"` - Arrival MediumBahnTime `json:"ankunftszeit"` + Departure mediumBahnTime `json:"abfahrtszeit"` + Arrival mediumBahnTime `json:"ankunftszeit"` Station string `json:"bahnhofsname"` EvaId string `json:"evanummer"` Platform string `json:"gleisbezeichnung"` diff --git a/external_station.go b/external_station.go index 9e1c571c5c1d80854bf533548fe564a9cfd5874c..e3d11cbb18ff7efd60a677762baef900aaed5f8b 100644 --- a/external_station.go +++ b/external_station.go @@ -32,13 +32,13 @@ func parseStations(data rawStations) []Station { } type rawStation struct { - Platforms *BahnStringList `xml:"p,attr,omitempty"` - Meta *BahnStringList `xml:"meta,attr,omitempty"` + Platforms *bahnStringList `xml:"p,attr,omitempty"` + Meta *bahnStringList `xml:"meta,attr,omitempty"` StationName string `xml:"name,attr,omitempty"` EvaId string `xml:"eva,attr,omitempty"` StationCode string `xml:"ds100,attr,omitempty"` Db bool `xml:"db,attr,omitempty"` - CreatedAt *BahnTime `xml:"creationts,attr,omitempty"` + CreatedAt *bahnTime `xml:"creationts,attr,omitempty"` } func parseStation(data rawStation) Station { diff --git a/external_timetable.go b/external_timetable.go index be4f0b2609875cc3495b2d2ea8742aca3d006b22..6665990fbc864012c0a601e4db3b3fcb3fa03621 100644 --- a/external_timetable.go +++ b/external_timetable.go @@ -41,14 +41,14 @@ func parseTimetable(data rawTimetable) Timetable { type rawMessage struct { MessageId string `xml:"id,attr,omitempty"` Type rawMessageType `xml:"t,attr,omitempty"` - From *ShortBahnTime `xml:"from,attr,omitempty"` - To *ShortBahnTime `xml:"to,attr,omitempty"` + From *shortBahnTime `xml:"from,attr,omitempty"` + To *shortBahnTime `xml:"to,attr,omitempty"` Code *int `xml:"c,attr,omitempty"` InternalText string `xml:"int,attr,omitempty"` ExternalText string `xml:"ext,attr,omitempty"` Category string `xml:"cat,attr,omitempty"` ExternalCategory string `xml:"ec,attr,omitempty"` - Timestamp *ShortBahnTime `xml:"ts,attr,omitempty"` + Timestamp *shortBahnTime `xml:"ts,attr,omitempty"` Priority rawPriority `xml:"pr,attr,omitempty"` Owner string `xml:"o,attr,omitempty"` ExternalLink string `xml:"elnk,attr,omitempty"` @@ -187,7 +187,7 @@ type rawDistributorMessage struct { DistributorType rawDistributorType `xml:"t,attr,omitempty"` DistributorName string `xml:"n,attr,omitempty"` InternalText string `xml:"int,attr,omitempty"` - Timestamp *ShortBahnTime `xml:"ts,attr,omitempty"` + Timestamp *shortBahnTime `xml:"ts,attr,omitempty"` } func parseDistributorMessages(data []rawDistributorMessage) []DistributorMessage { @@ -260,7 +260,7 @@ func parseTimetableStop(data rawTimetableStop) TimetableStop { type rawTripLabel struct { Messages []rawMessage `xml:"m,omitempty"` - CreatedAt *ShortBahnTime `xml:"ct,attr"` + CreatedAt *shortBahnTime `xml:"ct,attr"` FilterFlag rawFilterFlag `xml:"f,attr,omitempty"` TripType rawTripType `xml:"t,attr,omitempty"` Owner string `xml:"o,attr,omitempty"` @@ -343,9 +343,9 @@ func parseTripType(data rawTripType) TripType { } type rawHistoricDelay struct { - Timestamp *ShortBahnTime `xml:"ts,attr"` - Arrival *ShortBahnTime `xml:"ar,attr"` - Departure *ShortBahnTime `xml:"dp,attr"` + Timestamp *shortBahnTime `xml:"ts,attr"` + Arrival *shortBahnTime `xml:"ar,attr"` + Departure *shortBahnTime `xml:"dp,attr"` Source rawDelaySource `xml:"src,attr"` Code string `xml:"cod,attr"` } @@ -406,7 +406,7 @@ func parseDelaySource(data rawDelaySource) DelaySource { } type rawHistoricPlatformChange struct { - Timestamp *ShortBahnTime `xml:"ts,attr,omitempty"` + Timestamp *shortBahnTime `xml:"ts,attr,omitempty"` ArrivalPlatform string `xml:"ar,attr,omitempty"` DeparturePlatform string `xml:"dp,attr,omitempty"` Cause string `xml:"cot,attr,omitempty"` @@ -431,7 +431,7 @@ func parseHistoricPlatformChange(data rawHistoricPlatformChange) HistoricPlatfor type rawConnection struct { ConnectionId string `xml:"id,attr,omitempty"` - Timestamp *ShortBahnTime `xml:"ts,attr,omitempty"` + Timestamp *shortBahnTime `xml:"ts,attr,omitempty"` EvaId int64 `xml:"eva,attr,omitempty"` ConnectionStatus rawConnectionStatus `xml:"cs,attr,omitempty"` Ref *rawTimetableStop `xml:"ref,omitempty"` @@ -519,12 +519,12 @@ type rawEvent struct { Messages []rawMessage `xml:"m,omitempty"` PlannedPlatform string `xml:"pp,attr,omitempty"` - PlannedTime *ShortBahnTime `xml:"pt,attr,omitempty"` - PlannedPath *BahnStringList `xml:"ppth,attr,omitempty"` + PlannedTime *shortBahnTime `xml:"pt,attr,omitempty"` + PlannedPath *bahnStringList `xml:"ppth,attr,omitempty"` PlannedDestination string `xml:"pde,attr,omitempty"` ChangedPlatform string `xml:"cp,attr,omitempty"` - ChangedTime *ShortBahnTime `xml:"ct,attr"` - ChangedPath *BahnStringList `xml:"cpth,attr,omitempty"` + ChangedTime *shortBahnTime `xml:"ct,attr"` + ChangedPath *bahnStringList `xml:"cpth,attr,omitempty"` ChangedDestination string `xml:"cde,attr,omitempty"` PlannedStatus rawEventStatus `xml:"ps,attr,omitempty"` ChangedStatus rawEventStatus `xml:"cs,attr,omitempty"` diff --git a/types_util.go b/types_util.go index de857c0119ec4edd6e4d611746122abd0fbf2662..4482d05de2c4edb94367da12c0668d0bf0c45296 100644 --- a/types_util.go +++ b/types_util.go @@ -7,9 +7,9 @@ import ( "time" ) -type BahnStringList []string +type bahnStringList []string -func (s *BahnStringList) MarshalXMLAttr(name xml.Name) (xml.Attr, error) { +func (s *bahnStringList) MarshalXMLAttr(name xml.Name) (xml.Attr, error) { if s == nil { return xml.Attr{}, nil } else { @@ -20,12 +20,12 @@ func (s *BahnStringList) MarshalXMLAttr(name xml.Name) (xml.Attr, error) { } } -func (s *BahnStringList) UnmarshalXMLAttr(attr xml.Attr) error { +func (s *bahnStringList) UnmarshalXMLAttr(attr xml.Attr) error { *s = strings.Split(attr.Value, "|") return nil } -func (s *BahnStringList) Value() []string { +func (s *bahnStringList) Value() []string { if s != nil { return *s } else { @@ -33,26 +33,26 @@ func (s *BahnStringList) Value() []string { } } -type BahnTime struct { +type bahnTime struct { time.Time } -const BahnTimeLayout = "06-01-02 15:04:05.999" +const bahnTimeLayout = "06-01-02 15:04:05.999" -func (t *BahnTime) MarshalXMLAttr(name xml.Name) (xml.Attr, error) { +func (t *bahnTime) MarshalXMLAttr(name xml.Name) (xml.Attr, error) { if t == nil || t.IsZero() { return xml.Attr{}, nil } else { return xml.Attr{ Name: name, - Value: t.Format(BahnTimeLayout), + Value: t.Format(bahnTimeLayout), }, nil } } -func (t *BahnTime) UnmarshalXMLAttr(attr xml.Attr) error { +func (t *bahnTime) UnmarshalXMLAttr(attr xml.Attr) error { if attr.Value != "" { - value, err := time.Parse(BahnTimeLayout, attr.Value) + value, err := time.Parse(bahnTimeLayout, attr.Value) if err != nil { return err } @@ -61,7 +61,7 @@ func (t *BahnTime) UnmarshalXMLAttr(attr xml.Attr) error { return nil } -func (t *BahnTime) Value() *time.Time { +func (t *bahnTime) Value() *time.Time { if t != nil { return &t.Time } else { @@ -69,26 +69,26 @@ func (t *BahnTime) Value() *time.Time { } } -type ShortBahnTime struct { +type shortBahnTime struct { time.Time } -const ShortBahnTimeLayout = "0601021504" +const shortBahnTimeLayout = "0601021504" -func (t *ShortBahnTime) MarshalXMLAttr(name xml.Name) (xml.Attr, error) { +func (t *shortBahnTime) MarshalXMLAttr(name xml.Name) (xml.Attr, error) { if t == nil || t.IsZero() { return xml.Attr{}, nil } else { return xml.Attr{ Name: name, - Value: t.Format(ShortBahnTimeLayout), + Value: t.Format(shortBahnTimeLayout), }, nil } } -func (t *ShortBahnTime) UnmarshalXMLAttr(attr xml.Attr) error { +func (t *shortBahnTime) UnmarshalXMLAttr(attr xml.Attr) error { if attr.Value != "" { - value, err := time.Parse(ShortBahnTimeLayout, attr.Value) + value, err := time.Parse(shortBahnTimeLayout, attr.Value) if err != nil { return err } @@ -97,7 +97,7 @@ func (t *ShortBahnTime) UnmarshalXMLAttr(attr xml.Attr) error { return nil } -func (t *ShortBahnTime) Value() *time.Time { +func (t *shortBahnTime) Value() *time.Time { if t != nil { return &t.Time } else { @@ -105,26 +105,26 @@ func (t *ShortBahnTime) Value() *time.Time { } } -type MediumBahnTime struct { +type mediumBahnTime struct { time.Time } -const MediumBahnTimeLayout = "2006-01-02T15:04:05" +const mediumBahnTimeLayout = "2006-01-02T15:04:05" -func (t *MediumBahnTime) MarshalXMLAttr(name xml.Name) (xml.Attr, error) { +func (t *mediumBahnTime) MarshalXMLAttr(name xml.Name) (xml.Attr, error) { if t == nil || t.IsZero() { return xml.Attr{}, nil } else { return xml.Attr{ Name: name, - Value: t.Format(MediumBahnTimeLayout), + Value: t.Format(mediumBahnTimeLayout), }, nil } } -func (t *MediumBahnTime) UnmarshalXMLAttr(attr xml.Attr) error { +func (t *mediumBahnTime) UnmarshalXMLAttr(attr xml.Attr) error { if attr.Value != "" { - value, err := time.Parse(MediumBahnTimeLayout, attr.Value) + value, err := time.Parse(mediumBahnTimeLayout, attr.Value) if err != nil { return err } @@ -133,17 +133,17 @@ func (t *MediumBahnTime) UnmarshalXMLAttr(attr xml.Attr) error { return nil } -func (t *MediumBahnTime) MarshalJSON() ([]byte, error) { +func (t *mediumBahnTime) MarshalJSON() ([]byte, error) { var text string if t == nil || t.IsZero() { text = "" } else { - text = t.Format(MediumBahnTimeLayout) + text = t.Format(mediumBahnTimeLayout) } return json.Marshal(&text) } -func (t *MediumBahnTime) UnmarshalJSON(data []byte) error { +func (t *mediumBahnTime) UnmarshalJSON(data []byte) error { var err error var text string @@ -153,7 +153,7 @@ func (t *MediumBahnTime) UnmarshalJSON(data []byte) error { if text != "" { var value time.Time - if value, err = time.Parse(MediumBahnTimeLayout, text); err != nil { + if value, err = time.Parse(mediumBahnTimeLayout, text); err != nil { return err } t.Time = value @@ -161,7 +161,7 @@ func (t *MediumBahnTime) UnmarshalJSON(data []byte) error { return nil } -func (t *MediumBahnTime) Value() *time.Time { +func (t *mediumBahnTime) Value() *time.Time { if t != nil { return &t.Time } else { @@ -169,26 +169,26 @@ func (t *MediumBahnTime) Value() *time.Time { } } -type BahnDate struct { +type bahnDate struct { time.Time } -const BahnDateLayout = "2006-01-02" +const bahnDateLayout = "2006-01-02" -func (t *BahnDate) MarshalXMLAttr(name xml.Name) (xml.Attr, error) { +func (t *bahnDate) MarshalXMLAttr(name xml.Name) (xml.Attr, error) { if t == nil || t.IsZero() { return xml.Attr{}, nil } else { return xml.Attr{ Name: name, - Value: t.Format(BahnDateLayout), + Value: t.Format(bahnDateLayout), }, nil } } -func (t *BahnDate) UnmarshalXMLAttr(attr xml.Attr) error { +func (t *bahnDate) UnmarshalXMLAttr(attr xml.Attr) error { if attr.Value != "" { - value, err := time.Parse(BahnDateLayout, attr.Value) + value, err := time.Parse(bahnDateLayout, attr.Value) if err != nil { return err } @@ -197,17 +197,17 @@ func (t *BahnDate) UnmarshalXMLAttr(attr xml.Attr) error { return nil } -func (t *BahnDate) MarshalJSON() ([]byte, error) { +func (t *bahnDate) MarshalJSON() ([]byte, error) { var text string if t == nil || t.IsZero() { text = "" } else { - text = t.Format(BahnDateLayout) + text = t.Format(bahnDateLayout) } return json.Marshal(&text) } -func (t *BahnDate) UnmarshalJSON(data []byte) error { +func (t *bahnDate) UnmarshalJSON(data []byte) error { var err error var text string @@ -217,7 +217,7 @@ func (t *BahnDate) UnmarshalJSON(data []byte) error { if text != "" { var value time.Time - if value, err = time.Parse(BahnDateLayout, text); err != nil { + if value, err = time.Parse(bahnDateLayout, text); err != nil { return err } t.Time = value @@ -225,7 +225,7 @@ func (t *BahnDate) UnmarshalJSON(data []byte) error { return nil } -func (t *BahnDate) Value() *time.Time { +func (t *bahnDate) Value() *time.Time { if t != nil { return &t.Time } else {