From 97d6046e30ec358483309915752dfc770bb5fdd6 Mon Sep 17 00:00:00 2001 From: emilyboda Date: Thu, 4 Jun 2020 15:39:47 -0400 Subject: [PATCH 1/2] forecasted times are now in 12 hr format when requested Previously showed only 24 hr time, no matter what was requested. I edited it so that when hours = "12", the time format will be 12 hr time format. --- modules/inkycal_weather.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/inkycal_weather.py b/modules/inkycal_weather.py index 6e361cf..3369dfc 100644 --- a/modules/inkycal_weather.py +++ b/modules/inkycal_weather.py @@ -143,7 +143,7 @@ def to_hours(datetime_object, simple = False): converted_time = datetime_object.format('HH:mm') else: if simple == True: - converted_time = datetime_object.format('H a') + converted_time = datetime_object.format('h a') else: converted_time = datetime_object.format('hh:mm') return str(converted_time) From 0843aa8943a7f1f3e48aaad08f8026ce9a25f04a Mon Sep 17 00:00:00 2001 From: emilyboda Date: Thu, 4 Jun 2020 15:40:26 -0400 Subject: [PATCH 2/2] made the 3hr forecast time respect local timezone 1. converted the now variable to local TZ 2. the forecast.get_weather_at function still requires UTC, so I added a TZ conversion back to UTC. --- modules/inkycal_weather.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/inkycal_weather.py b/modules/inkycal_weather.py index 3369dfc..e9d4943 100644 --- a/modules/inkycal_weather.py +++ b/modules/inkycal_weather.py @@ -171,7 +171,7 @@ def generate_image(): forecast = owm.three_hours_forecast(location) """Round the hour to the nearest multiple of 3""" - now = arrow.utcnow() + now = arrow.utcnow().to(get_tz()) if (now.hour % 3) != 0: hour_gap = 3 - (now.hour % 3) else: @@ -184,10 +184,10 @@ def generate_image(): fc4 = now.replace(hours = + hour_gap + 9).floor('hour') """Prepare forecast objects for the specified timings""" - forecast_fc1 = forecast.get_weather_at(fc1.datetime) - forecast_fc2 = forecast.get_weather_at(fc2.datetime) - forecast_fc3 = forecast.get_weather_at(fc3.datetime) - forecast_fc4 = forecast.get_weather_at(fc4.datetime) + forecast_fc1 = forecast.get_weather_at(fc1.datetime.astimezone(timezone('UTC'))) + forecast_fc2 = forecast.get_weather_at(fc2.datetime.astimezone(timezone('UTC'))) + forecast_fc3 = forecast.get_weather_at(fc3.datetime.astimezone(timezone('UTC'))) + forecast_fc4 = forecast.get_weather_at(fc4.datetime.astimezone(timezone('UTC'))) """Get the current temperature and forcasts temperatures""" temperature_now = to_units(weather.get_temperature()['temp'])