1
1
import { ClimateType , StorageKey , Units } from 'enums/index' ;
2
2
import { AirPollution , Weather } from 'interfaces/index' ;
3
3
4
- import { getLastDateChecked , getLastDateCheckedAmerican , getLastTimeChecked , getLastTimeChecked12HoursFormat , getWindDirection } from './helpers' ;
4
+ import { getLastDateChecked , getLastDateCheckedAmerican , getLastTimeChecked , getLastTimeChecked12HoursFormat , getWindDirection , truncateToOneDecimal } from './helpers' ;
5
5
6
6
export const convertOpenWeatherMapResponseToInterface = ( climateType : ClimateType , unit : Units , object : any ) => {
7
7
switch ( climateType ) {
@@ -16,15 +16,15 @@ export const convertOpenWeatherMapResponseToInterface = (climateType: ClimateTyp
16
16
17
17
const convertToWeather = ( object : any , unit : Units ) => {
18
18
return {
19
- realFeel : Math . trunc ( object . main . temp ) ,
20
- feelsLike : Math . trunc ( object . main . feels_like ) ,
19
+ realFeel : Math . round ( object . main . temp ) ,
20
+ feelsLike : Math . round ( object . main . feels_like ) ,
21
21
description : object . weather [ 0 ] . description . charAt ( 0 ) . toUpperCase ( ) + object . weather [ 0 ] . description . substring ( 1 ) ,
22
22
icon : "" ,
23
23
humidity : object . main . humidity ,
24
24
pressure : object . main . pressure ,
25
- windSpeed : Units . Imperial === unit ? Math . trunc ( object . wind . speed ) : Math . trunc ( object . wind . speed * 3.6 ) ,
25
+ windSpeed : Units . Imperial === unit ? truncateToOneDecimal ( object . wind . speed ) : truncateToOneDecimal ( object . wind . speed * 3.6 ) ,
26
26
windDirection : getWindDirection ( object ) ,
27
- visibility : Units . Imperial === unit ? Math . trunc ( object . visibility / 1609.344 ) : object . visibility ,
27
+ visibility : Units . Imperial === unit ? truncateToOneDecimal ( object . visibility / 1609.344 ) : object . visibility ,
28
28
sunrise : object . sys . sunrise ,
29
29
sunset : object . sys . sunset ,
30
30
lastTimeChecked : localStorage . getItem ( StorageKey . Language ) === 'en' ? getLastTimeChecked12HoursFormat ( ) : getLastTimeChecked ( ) ,
0 commit comments