Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/aline-borges/blowy
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-menezes-torres committed Nov 17, 2020
2 parents db519c3 + 7f84c2b commit 30752c2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"react-native-safe-area-context": "3.1.4",
"react-native-screens": "~2.10.1",
"react-native-web": "~0.13.12",
"styled-components": "^5.2.0"
"styled-components": "^5.2.0",
"xdate": "^0.8.2"
},
"devDependencies": {
"@babel/core": "~7.9.0"
Expand Down
22 changes: 9 additions & 13 deletions src/screens/Locations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import AsyncStorage from '@react-native-community/async-storage';
import { LinearGradient } from 'expo-linear-gradient';
import { Feather } from '@expo/vector-icons';
import { SafeAreaView } from 'react-native-safe-area-context';
import { format, utcToZonedTime } from 'date-fns-tz';
import { getHours, getMinutes } from 'date-fns';
import 'date-time-format-timezone';

import OpenWeather, { getOneCall } from '../../services/apis/openWeather';

Expand All @@ -37,23 +34,22 @@ const Locations = ({ navigation }) => {
const response = await OpenWeather(city)
const response2 = await getOneCall(response.coord.lat, response.coord.lon);

const date = new Date(response2.current.dt * 1000 )
const timezone = response2.timezone;

const newDate = utcToZonedTime(date, timezone);
const date = new Date((response2.current.dt + response2.timezone_offset) * 1000)

const hour = date.getUTCHours();
const minutes = date.getUTCMinutes();
let newHour = ``;

const newHour = getHours(newDate, {locale: 'pt-BR'});
const newMinutes = getMinutes(newDate);
const h = newHour < 10 ? `0${newHour}` : newHour;
const m = newMinutes < 10 ? `0${newMinutes}` : newMinutes;
hour < 10 ? newHour = `0${hour}` : newHour = `${hour}`
console.log(newHour)

const newTime = `${h}:${m}`;
const time = `${newHour}:${minutes}`;

const datas = {data: response, data2: response2}
const location = {
data: response,
data2: response2,
hour: newTime
hour: time
}
locations.push(location);
}
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5844,6 +5844,11 @@ xcode@^3.0.0:
simple-plist "^1.1.0"
uuid "^7.0.3"

xdate@^0.8.2:
version "0.8.2"
resolved "https://registry.yarnpkg.com/xdate/-/xdate-0.8.2.tgz#d7b033c00485d02695baf0044f4eacda3fc961a3"
integrity sha1-17AzwASF0CaVuvAET06s2j/JYaM=

xml-js@^1.6.11:
version "1.6.11"
resolved "https://registry.yarnpkg.com/xml-js/-/xml-js-1.6.11.tgz#927d2f6947f7f1c19a316dd8eea3614e8b18f8e9"
Expand Down

0 comments on commit 30752c2

Please sign in to comment.