9
9
* This class is a provider for UK Met Office Datapoint.
10
10
*/
11
11
12
-
13
12
WeatherProvider . register ( "ukmetoffice" , {
14
13
15
14
// Set the name of the provider.
@@ -41,7 +40,7 @@ WeatherProvider.register("ukmetoffice", {
41
40
. catch ( function ( request ) {
42
41
Log . error ( "Could not load data ... " , request ) ;
43
42
} )
44
- . finally ( ( ) => this . updateAvailable ( ) )
43
+ . finally ( ( ) => this . updateAvailable ( ) ) ;
45
44
} ,
46
45
47
46
// Overwrite the fetchCurrentWeather method.
@@ -63,11 +62,9 @@ WeatherProvider.register("ukmetoffice", {
63
62
. catch ( function ( request ) {
64
63
Log . error ( "Could not load data ... " , request ) ;
65
64
} )
66
- . finally ( ( ) => this . updateAvailable ( ) )
65
+ . finally ( ( ) => this . updateAvailable ( ) ) ;
67
66
} ,
68
67
69
-
70
-
71
68
/** UK Met Office Specific Methods - These are not part of the default provider methods */
72
69
/*
73
70
* Gets the complete url for the request
@@ -83,13 +80,13 @@ WeatherProvider.register("ukmetoffice", {
83
80
const currentWeather = new WeatherObject ( this . config . units , this . config . tempUnits , this . config . windUnits ) ;
84
81
85
82
// data times are always UTC
86
- let nowUtc = moment . utc ( )
87
- let midnightUtc = nowUtc . clone ( ) . startOf ( "day" )
83
+ let nowUtc = moment . utc ( ) ;
84
+ let midnightUtc = nowUtc . clone ( ) . startOf ( "day" ) ;
88
85
let timeInMins = nowUtc . diff ( midnightUtc , "minutes" ) ;
89
86
90
87
// loop round each of the (5) periods, look for today (the first period may be yesterday)
91
88
for ( i in currentWeatherData . SiteRep . DV . Location . Period ) {
92
- let periodDate = moment . utc ( currentWeatherData . SiteRep . DV . Location . Period [ i ] . value . substr ( 0 , 10 ) , "YYYY-MM-DD" )
89
+ let periodDate = moment . utc ( currentWeatherData . SiteRep . DV . Location . Period [ i ] . value . substr ( 0 , 10 ) , "YYYY-MM-DD" ) ;
93
90
94
91
// ignore if period is before today
95
92
if ( periodDate . isSameOrAfter ( moment . utc ( ) . startOf ( "day" ) ) ) {
@@ -116,7 +113,7 @@ WeatherProvider.register("ukmetoffice", {
116
113
}
117
114
118
115
// determine the sunrise/sunset times - not supplied in UK Met Office data
119
- let times = this . calcAstroData ( currentWeatherData . SiteRep . DV . Location )
116
+ let times = this . calcAstroData ( currentWeatherData . SiteRep . DV . Location ) ;
120
117
currentWeather . sunrise = times [ 0 ] ;
121
118
currentWeather . sunset = times [ 1 ] ;
122
119
@@ -136,8 +133,8 @@ WeatherProvider.register("ukmetoffice", {
136
133
const weather = new WeatherObject ( this . config . units , this . config . tempUnits , this . config . windUnits ) ;
137
134
138
135
// data times are always UTC
139
- dateStr = forecasts . SiteRep . DV . Location . Period [ j ] . value
140
- let periodDate = moment . utc ( dateStr . substr ( 0 , 10 ) , "YYYY-MM-DD" )
136
+ dateStr = forecasts . SiteRep . DV . Location . Period [ j ] . value ;
137
+ let periodDate = moment . utc ( dateStr . substr ( 0 , 10 ) , "YYYY-MM-DD" ) ;
141
138
142
139
// ignore if period is before today
143
140
if ( periodDate . isSameOrAfter ( moment . utc ( ) . startOf ( "day" ) ) ) {
0 commit comments