@@ -161,18 +161,16 @@ struct ExchangeRatesCalculator {
161
161
dateFormatter. dateFormat = " dd/MMM/yy "
162
162
let interval : DateInterval ?
163
163
if let period = try document. nodes ( forXPath: " /exchangeRateMonthList/@Period " ) . first? . stringValue,
164
- period. count == 26
165
- {
164
+ period. count == 26 {
166
165
// "01/Sep/2018 to 30/Sep/2018"
167
166
let startString = period [ period. startIndex ..< period. index ( period. startIndex, offsetBy: 11 ) ]
168
167
let to = period [ startString. endIndex ..< period. index ( startString. endIndex, offsetBy: 4 ) ]
169
168
let endString = period [ to. endIndex ..< period. index ( to. endIndex, offsetBy: 11 ) ]
170
169
if let startDate = dateFormatter. date ( from: String ( startString) ) ,
171
- let startDay = calendar. dateInterval ( of: . day, for: startDate) ,
172
- to == " to " ,
173
- let endDate = dateFormatter. date ( from: String ( endString) ) ,
174
- let endDay = calendar. dateInterval ( of: . day, for: endDate)
175
- {
170
+ let startDay = calendar. dateInterval ( of: . day, for: startDate) ,
171
+ to == " to " ,
172
+ let endDate = dateFormatter. date ( from: String ( endString) ) ,
173
+ let endDay = calendar. dateInterval ( of: . day, for: endDate) {
176
174
interval = DateInterval ( start: startDay. start, end: endDay. end)
177
175
} else {
178
176
interval = nil
@@ -184,9 +182,8 @@ struct ExchangeRatesCalculator {
184
182
let ratesByCurrencyCode : [ String : Decimal ? ] = Dictionary ( uniqueKeysWithValues: try currencyCodes. map {
185
183
let xpathCurrency = $0. replacingOccurrences ( of: " ' " , with: " ' " )
186
184
if let rateString = try document. nodes ( forXPath: " /exchangeRateMonthList/exchangeRate/currencyCode[text()=' \( xpathCurrency) ']/../rateNew/text() " ) . first? . stringValue,
187
- // We must parse the decimal data using the UK locale, not the system one.
188
- let rate = Decimal ( string: rateString, locale: self . locale)
189
- {
185
+ // We must parse the decimal data using the UK locale, not the system one.
186
+ let rate = Decimal ( string: rateString, locale: self . locale) {
190
187
return ( $0, rate)
191
188
} else {
192
189
return ( $0, nil )
0 commit comments