From 343b05af04557aaaa68a627ad1bd8cd990aa6b4e Mon Sep 17 00:00:00 2001 From: Yuval Adam Date: Sun, 8 Nov 2015 13:57:24 +0200 Subject: Fix UTC->IL timestamps --- geshem.py | 3 ++- requirements.txt | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/geshem.py b/geshem.py index 67807d1..19eb984 100644 --- a/geshem.py +++ b/geshem.py @@ -5,6 +5,7 @@ from datetime import datetime from flask import Flask, render_template from os import environ from pathlib import Path +from pytz import utc, timezone from redis.exceptions import ConnectionError MAPS_JSON = 'http://map.govmap.gov.il/rainradar/radar.json' @@ -34,7 +35,7 @@ def home(): try: latests = redis.pipeline().get('latest_140').get('latest_280').execute() latest_140, latest_280 = map(lambda x: x.decode(), latests) - ts = datetime.strptime(latest_280, '%Y%m%d_%H%M%S') + ts = utc.localize(datetime.strptime(latest_280, '%Y%m%d_%H%M%S')).astimezone(timezone('Asia/Jerusalem')) except ConnectionError: latest_140, latest_280 = 'dev', 'dev' ts = datetime.now() diff --git a/requirements.txt b/requirements.txt index a7eacd1..c25b874 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,5 +4,6 @@ MarkupSafe==0.23 Werkzeug==0.10.4 gunicorn==19.3.0 itsdangerous==0.24 +pytz==2015.7 redis==2.10.5 requests==2.8.1 -- cgit v1.3.1