@@ -20,13 +20,23 @@ type Location struct {
20
20
Localtime Time `json:"localtime,omitempty"`
21
21
}
22
22
23
- type Current struct {
24
- LastUpdatedEpoch int64 `json:"last_updated_epoch"`
25
- LastUpdated Time `json:"last_updated,omitempty"`
26
- TempC float64 `json:"temp_c"`
27
- TempF float64 `json:"temp_f"`
28
- IsDay int `json:"is_day"` // Whether to show day condition icon (1) or night icon (0)
29
- Condition struct {
23
+ type CurrentConditions struct {
24
+ LastUpdatedEpoch int64 `json:"last_updated_epoch"`
25
+ LastUpdated Time `json:"last_updated,omitempty"`
26
+ Conditions
27
+ }
28
+
29
+ type ForecastConditions struct {
30
+ TimeEpoch int64 `json:"time_epoch"`
31
+ Time Time `json:"time,omitempty"`
32
+ Conditions
33
+ }
34
+
35
+ type Conditions struct {
36
+ TempC float64 `json:"temp_c"`
37
+ TempF float64 `json:"temp_f"`
38
+ IsDay int `json:"is_day"` // Whether to show day condition icon (1) or night icon (0)
39
+ Condition struct {
30
40
Text string `json:"text"`
31
41
Icon string `json:"icon"`
32
42
Code int `json:"code"`
@@ -50,11 +60,67 @@ type Current struct {
50
60
GustKph float64 `json:"gust_kph"`
51
61
}
52
62
63
+ type Day struct {
64
+ MaxTempC float64 `json:"maxtemp_c"`
65
+ MaxTempF float64 `json:"maxtemp_f"`
66
+ MinTempC float64 `json:"mintemp_c"`
67
+ MinTempF float64 `json:"mintemp_f"`
68
+ AvgTempC float64 `json:"avgtemp_c"`
69
+ AvgTempF float64 `json:"avgtemp_f"`
70
+ MaxWindMph float64 `json:"maxwind_mph"`
71
+ MaxWindKph float64 `json:"maxwind_kph"`
72
+ TotalPrecipMm float64 `json:"totalprecip_mm"`
73
+ TotalPrecipIn float64 `json:"totalprecip_in"`
74
+ TotalSnowCm float64 `json:"totalsnow_cm"`
75
+ AvgVisKm float64 `json:"avgvis_km"`
76
+ AvgVisMiles float64 `json:"avgvis_miles"`
77
+ AvgHumidity int `json:"avghumidity"`
78
+ WillItRain int `json:"daily_will_it_rain"`
79
+ WillItSnow int `json:"daily_will_it_snow"`
80
+ ChanceOfRainPercent int `json:"daily_chance_of_rain"`
81
+ ChanceOfSnowPercent int `json:"daily_chance_of_snow"`
82
+ Uv float32 `json:"uv"`
83
+ Condition struct {
84
+ Text string `json:"text"`
85
+ Icon string `json:"icon"`
86
+ Code int `json:"code"`
87
+ } `json:"condition"`
88
+ }
89
+
90
+ type ForecastDay struct {
91
+ Date string `json:"date"`
92
+ DateEpoch int64 `json:"date_epoch"`
93
+ Day * Day `json:"day"`
94
+ Hour []* ForecastConditions `json:"hour"`
95
+ Astro * Astro `json:"astro"`
96
+ }
97
+
98
+ type Astro struct {
99
+ SunRise string `json:"sunrise"`
100
+ SunSet string `json:"sunset"`
101
+ MoonRise string `json:"moonrise"`
102
+ MoonSet string `json:"moonset"`
103
+ MoonPhase string `json:"moon_phase"`
104
+ MoonIllumination int `json:"moon_illumination"`
105
+ IsMoonUp int `json:"is_moon_up"`
106
+ IsSunUp int `json:"is_sun_up"`
107
+ }
108
+
53
109
type Weather struct {
54
- Id int `json:"custom_id,omitempty"`
55
- Query string `json:"q,omitempty"`
56
- Location * Location `json:"location,omitempty"`
57
- Current * Current `json:"current,omitempty"`
110
+ Id int `json:"custom_id,omitempty"`
111
+ Query string `json:"q,omitempty"`
112
+ Location * Location `json:"location,omitempty"`
113
+ Current * CurrentConditions `json:"current,omitempty"`
114
+ }
115
+
116
+ type Forecast struct {
117
+ Id int `json:"custom_id,omitempty"`
118
+ Query string `json:"q,omitempty"`
119
+ Location * Location `json:"location,omitempty"`
120
+ Current * CurrentConditions `json:"current,omitempty"`
121
+ Forecast struct {
122
+ Day []* ForecastDay `json:"forecastday"`
123
+ } `json:"forecast,omitempty"`
58
124
}
59
125
60
126
type Time struct {
@@ -69,6 +135,11 @@ func (w Weather) String() string {
69
135
return string (data )
70
136
}
71
137
138
+ func (f Forecast ) String () string {
139
+ data , _ := json .MarshalIndent (f , "" , " " )
140
+ return string (data )
141
+ }
142
+
72
143
///////////////////////////////////////////////////////////////////////////////
73
144
// MARSHAL TIME
74
145
0 commit comments