Skip to content

Commit eba7d9e

Browse files
committed
Fix weather
1 parent 2691129 commit eba7d9e

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

Diff for: app/blueprints/home/helper.py

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ def get_index():
1717
}
1818
elif functions[i].__doc__:
1919
spl = functions[i].__doc__.split("Example: ")
20-
print(spl)
2120
route = f"/{'/'.join(str(j).split('/')[2:])}"
2221
dtype = search("<(.*):", route)
2322
default = True if dtype else False

Diff for: app/blueprints/weather/__init__.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import portolan
44
from flask import Blueprint, redirect, request
5+
from pytz import UTC, timezone
56

67
from app import app, omw, rounder
78

@@ -22,8 +23,10 @@ def current():
2223
data = omw.get(
2324
f"/data/2.5/weather?lat=36.99&lon=-122.06&units=imperial&appid={app.config['OPENWEATHER_KEY']}"
2425
).json()
25-
sunrise = datetime.fromtimestamp(int(data["sys"]["sunrise"]))
26-
sunset = datetime.fromtimestamp(int(data["sys"]["sunset"]))
26+
a = datetime.fromtimestamp(int(data["sys"]["sunrise"]))
27+
b = datetime.fromtimestamp(int(data["sys"]["sunset"]))
28+
sunrise = a.astimezone(timezone("US/Pacific"))
29+
sunset = b.astimezone(timezone("US/Pacific"))
2730

2831
return {
2932
"name": data["name"],
@@ -34,7 +37,7 @@ def current():
3437
"wind": {
3538
"speed": f"{rounder(data['wind']['speed'])} mph",
3639
"dir": portolan.abbr(degree=data["wind"]["deg"]),
37-
"gust": f"{data['wind']['gust']} mph",
40+
"gust": f"{rounder(data['wind']['gust'])} mph",
3841
},
3942
"sunrise": sunrise.strftime("%-I:%M %p"),
4043
"sunset": sunset.strftime("%-I:%M %p"),

Diff for: app/helper.py

-1
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,4 @@ def readify(text):
6565
def rounder(num):
6666
with localcontext() as ctx:
6767
ctx.rounding = ROUND_HALF_UP
68-
print(num)
6968
return Decimal(num).to_integral_value()

0 commit comments

Comments
 (0)