mirror of
https://github.com/imjasonh/staticmaps
synced 2026-07-10 12:11:46 +00:00
Add doc comments for Time Zone API methods
This commit is contained in:
parent
a3e86dd287
commit
0746d8fc00
1 changed files with 26 additions and 3 deletions
29
timezone.go
29
timezone.go
|
|
@ -6,6 +6,9 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
// TimeZone requests time zone information about a location.
|
||||
//
|
||||
// See https://developers.google.com/maps/documentation/timezone/
|
||||
func (c Client) TimeZone(ll LatLng, t time.Time, opts *TimeZoneOpts) (*TimeZoneResult, error) {
|
||||
var r timeZoneResponse
|
||||
if err := c.doDecode(baseURL+timezone(ll, t, opts), &r); err != nil {
|
||||
|
|
@ -25,7 +28,11 @@ func timezone(ll LatLng, t time.Time, opts *TimeZoneOpts) string {
|
|||
return "timezone/json?" + p.Encode()
|
||||
}
|
||||
|
||||
// TimeZoneOpts defines options for TimeZone requests.
|
||||
type TimeZoneOpts struct {
|
||||
// The language in which to return results.
|
||||
//
|
||||
// See https://developers.google.com/maps/faq#languagesupport
|
||||
Language string
|
||||
}
|
||||
|
||||
|
|
@ -44,17 +51,33 @@ type timeZoneResponse struct {
|
|||
TimeZoneResult
|
||||
}
|
||||
|
||||
// TimeZoneResult describes information about the time zone at the requested location.
|
||||
type TimeZoneResult struct {
|
||||
DSTOffset int64 `json:"dstOffset"` // secs offset for DST
|
||||
RawOffset int64 `json:"rawOffset"`
|
||||
TimeZoneID string `json:"timeZoneId"`
|
||||
// DSTOffset is the offset for daylight-savings time in seconds.
|
||||
//
|
||||
// This will be zero if the time zone is not in Daylight Savings Time during the specified time.
|
||||
DSTOffset int64 `json:"dstOffset"`
|
||||
|
||||
// RawOffset is the offset from UTC (in seconds) for the given location.
|
||||
//
|
||||
// This does not take into effect daylight savings.
|
||||
RawOffset int64 `json:"rawOffset"`
|
||||
|
||||
// TimeZoneID is a string containing the "tz" ID of the time zone, such as "America/Los_Angeles"
|
||||
TimeZoneID string `json:"timeZoneId"`
|
||||
|
||||
// TimeZoneName is a string containing the long form name of the time zone, e.g., "Pacific Daylight Time".
|
||||
//
|
||||
// This field will be localized if the Language was specified.
|
||||
TimeZoneName string `json:"timeZoneName"`
|
||||
}
|
||||
|
||||
// DSTOffsetDuration translates the DSTOffset into a time.Duration
|
||||
func (r TimeZoneResult) DSTOffsetDuration() time.Duration {
|
||||
return time.Duration(r.DSTOffset) * time.Second
|
||||
}
|
||||
|
||||
// RawOffsetDuration translates the RawOffset into a time.Duration
|
||||
func (r TimeZoneResult) RawOffsetDuration() time.Duration {
|
||||
return time.Duration(r.RawOffset) * time.Second
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue