Documentation
¶
Overview ¶
Package model defines data types for the Swiss public transport API responses.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var SwissLocation = func() *time.Location { loc, err := time.LoadLocation("Europe/Zurich") if err != nil { loc = time.FixedZone("CET", 1*60*60) } return loc }()
SwissLocation is the time zone for Switzerland (CET/CEST, Europe/Zurich). main.go imports _ "time/tzdata" so the embedded TZ database is always available; the fixed-offset fallback is a last-resort safety net only and does not handle the CET↔CEST daylight-saving transition.
Functions ¶
This section is empty.
Types ¶
type Arrival ¶
type Arrival struct {
Station Station `json:"station"`
Scheduled Timestamp `json:"arrival"`
Platform string `json:"platform"`
Delay int `json:"delay"`
}
Arrival holds arrival information for a connection section.
type Connection ¶
type Connection struct {
From struct {
Station Station `json:"station"`
Departure Timestamp `json:"departure"`
Delay int `json:"delay"`
Platform string `json:"platform"`
} `json:"from"`
To struct {
Station Station `json:"station"`
Arrival Timestamp `json:"arrival"`
Platform string `json:"platform"`
} `json:"to"`
Duration string `json:"duration"`
Transfers int `json:"transfers"`
Sections []Section `json:"sections"`
}
Connection represents a complete route between two stations.
type Coordinate ¶
Coordinate represents a geographic position.
type Departure ¶
type Departure struct {
Station Station `json:"station"`
Scheduled Timestamp `json:"departure"`
Platform string `json:"platform"`
Delay int `json:"delay"`
}
Departure holds departure information for a connection section.
type Section ¶
type Section struct {
Journey *struct {
Category string `json:"category"`
Number string `json:"number"`
Operator string `json:"operator"`
To string `json:"to"`
} `json:"journey"`
Walk *struct {
Duration int `json:"duration"`
Departure Departure `json:"departure"`
Arrival Arrival `json:"arrival"`
} `json:"walk"`
Departure Departure `json:"departure"`
Arrival Arrival `json:"arrival"`
}
Section represents a leg of a connection (either a journey or a walk).
type Station ¶
type Station struct {
Name string `json:"name"`
Coordinate Coordinate `json:"coordinate"`
}
Station represents a transport stop or station.
type Timestamp ¶
Timestamp wraps time.Time with custom JSON unmarshaling for the SBB API date format (2006-01-02T15:04:05-0700).
func (Timestamp) Local ¶
Local overrides time.Time.Local() to return the timestamp in Swiss time (CET/CEST, Europe/Zurich) instead of the system's local timezone.
func (*Timestamp) UnmarshalJSON ¶
UnmarshalJSON parses the SBB API date format into a Timestamp.