From e3876ec85d16d97b25cfe886ef9ab1d00866b3a6 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Sat, 14 Oct 2017 10:05:29 +0200 Subject: [PATCH] timestamp takes into account non UTC in weather --- rowers/weather.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/rowers/weather.py b/rowers/weather.py index 9acf5154..3e9bd4e0 100644 --- a/rowers/weather.py +++ b/rowers/weather.py @@ -5,6 +5,7 @@ import xml.etree.ElementTree as ET import time from datetime import datetime from rowingdata import rowingdata,geo_distance +import arrow import pandas as pd from rowers.models import Rower, Workout @@ -36,8 +37,8 @@ def get_weather_data(long,lat,unixtime): # Get Metar data def get_metar_data(airportcode,unixtime): - timestamp = datetime.utcfromtimestamp(unixtime).isoformat()+'Z' - + timestamp = arrow.get(unixtime).isoformat() + url = "https://www.aviationweather.gov/adds/dataserver_current/httpparam?dataSource=metars&requestType=retrieve&format=xml&startTime=" url += str(unixtime-3600) url += "&endTime=" @@ -122,8 +123,8 @@ def get_wind_data(lat,long,unixtime): windspeed = windspeed*(0.1)**0.34 windspeed = 0.01*int(100*windspeed) - timestamp = datetime.utcfromtimestamp(unixtime).isoformat()+'Z' - + timestamp = arrow.get(unixtime).isoformat() + message = 'Summary for your location at '+timestamp+': '+summary message += '. Temperature '+str(temperature)+'F/'+str(temperaturec)+'C'