comparison pkg/soap/nts/service.go @ 3580:d38b20ccb6f9

GM import: Be more graceful when accepting measure/issue dates.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 03 Jun 2019 17:55:49 +0200
parents 9ae43313b463
children d4a8d084eab4
comparison
equal deleted inserted replaced
3579:571801483a70 3580:d38b20ccb6f9
16 import ( 16 import (
17 "crypto/tls" 17 "crypto/tls"
18 "encoding/xml" 18 "encoding/xml"
19 "time" 19 "time"
20 20
21 "gemma.intevation.de/gemma/pkg/misc"
21 "gemma.intevation.de/gemma/pkg/soap" 22 "gemma.intevation.de/gemma/pkg/soap"
22 ) 23 )
23 24
24 // against "unused imports" 25 var guessDateTime = misc.TimeGuesser([]string{
25 var _ time.Time 26 "2006-01-02T15:04:05",
26 var _ xml.Name 27 "2006-01-02T15:04:05-07:00",
28 }).Guess
29
30 type DateTime struct{ time.Time }
31
32 func (dt *DateTime) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
33 var value string
34 if err := d.DecodeElement(&value, &start); err != nil {
35 return err
36 }
37 t, err := guessDateTime(value)
38 if err != nil {
39 return err
40 }
41 *dt = DateTime{t}
42 return nil
43 }
27 44
28 type Message_type_type string 45 type Message_type_type string
29 46
30 const ( 47 const (
31 Message_type_typeFTM Message_type_type = "FTM" 48 Message_type_typeFTM Message_type_type = "FTM"
122 139
123 Total_count bool `xml:"total_count,omitempty"` 140 Total_count bool `xml:"total_count,omitempty"`
124 } 141 }
125 142
126 type Paging_result_type struct { 143 type Paging_result_type struct {
127 XMLName xml.Name `xml:"http://www.ris.eu/nts/4.0.4.0 paging_result"` 144 XMLName xml.Name `xml:"http://www.ris.eu/nts.ms/2.0.4.0 paging_result"`
128 145
129 Offset *NonNegativeInteger `xml:"offset,omitempty"` 146 Offset *NonNegativeInteger `xml:"offset,omitempty"`
130 147
131 Count *NonNegativeInteger `xml:"count,omitempty"` 148 Count *NonNegativeInteger `xml:"count,omitempty"`
132 149
1170 1187
1171 // District / Region within the specified country, where the message is applicable 1188 // District / Region within the specified country, where the message is applicable
1172 District string `xml:"district,omitempty"` 1189 District string `xml:"district,omitempty"`
1173 1190
1174 // Date and time of publication including time zone 1191 // Date and time of publication including time zone
1175 Date_issue time.Time `xml:"date_issue,omitempty"` 1192 Date_issue DateTime `xml:"date_issue,omitempty"`
1176 } 1193 }
1177 1194
1178 type Ftm_type struct { 1195 type Ftm_type struct {
1179 XMLName xml.Name `xml:"http://www.ris.eu/nts/4.0.4.0 ftm_type"` 1196 XMLName xml.Name `xml:"http://www.ris.eu/nts/4.0.4.0 ftm_type"`
1180 1197
1289 1306
1290 // Regime applicable 1307 // Regime applicable
1291 Regime_code *Regime_code_enum `xml:"regime_code,omitempty"` 1308 Regime_code *Regime_code_enum `xml:"regime_code,omitempty"`
1292 1309
1293 // Date and Time of measurement or predicted value including time zone 1310 // Date and Time of measurement or predicted value including time zone
1294 Measuredate time.Time `xml:"measuredate,omitempty"` 1311 Measuredate DateTime `xml:"measuredate,omitempty"`
1295 1312
1296 // Difference with comparative value 1313 // Difference with comparative value
1297 Difference *Difference_type `xml:"difference,omitempty"` 1314 Difference *Difference_type `xml:"difference,omitempty"`
1298 } 1315 }
1299 1316
1328 1345
1329 type Ice_condition_type struct { 1346 type Ice_condition_type struct {
1330 XMLName xml.Name `xml:"http://www.ris.eu/nts/4.0.4.0 ice_condition_type"` 1347 XMLName xml.Name `xml:"http://www.ris.eu/nts/4.0.4.0 ice_condition_type"`
1331 1348
1332 // Date and Time of measurement or prediction including time zone 1349 // Date and Time of measurement or prediction including time zone
1333 Measuredate time.Time `xml:"measuredate,omitempty"` 1350 Measuredate DateTime `xml:"measuredate,omitempty"`
1334 1351
1335 // Condition code 1352 // Condition code
1336 Ice_condition_code *Ice_condition_code_enum `xml:"ice_condition_code,omitempty"` 1353 Ice_condition_code *Ice_condition_code_enum `xml:"ice_condition_code,omitempty"`
1337 1354
1338 // Accessibility code 1355 // Accessibility code
1373 1390
1374 type Weather_report_type struct { 1391 type Weather_report_type struct {
1375 XMLName xml.Name `xml:"http://www.ris.eu/nts/4.0.4.0 weather_report_type"` 1392 XMLName xml.Name `xml:"http://www.ris.eu/nts/4.0.4.0 weather_report_type"`
1376 1393
1377 // Date and time of measurement or predicted value including timezone 1394 // Date and time of measurement or predicted value including timezone
1378 Measuredate time.Time `xml:"measuredate,omitempty"` 1395 Measuredate DateTime `xml:"measuredate,omitempty"`
1379 1396
1380 // Forecast (true or 1) OR Actual report (false or 0) 1397 // Forecast (true or 1) OR Actual report (false or 0)
1381 Forecast bool `xml:"forecast,omitempty"` 1398 Forecast bool `xml:"forecast,omitempty"`
1382 1399
1383 // Classification of weather report 1400 // Classification of weather report