Skip to content

Matrix Portal Moon Clock fix for Circuitpython 7 #1905

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Matrix_Portal_Moon_Clock/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ def parse_time(timestring, is_dst=-1):
date_time = timestring.split('T') # Separate into date and time
year_month_day = date_time[0].split('-') # Separate time into Y/M/D
hour_minute_second = date_time[1].split('+')[0].split('-')[0].split(':')
return time.struct_time(int(year_month_day[0]),
return time.struct_time((int(year_month_day[0]),
int(year_month_day[1]),
int(year_month_day[2]),
int(hour_minute_second[0]),
int(hour_minute_second[1]),
int(hour_minute_second[2].split('.')[0]),
-1, -1, is_dst)
-1, -1, is_dst))


def update_time(timezone=None):
Expand Down Expand Up @@ -126,14 +126,14 @@ def __init__(self, datetime, hours_ahead, utc_offset):
# Can't change attribute in datetime struct, need to create
# a new one which will roll the date ahead as needed. Convert
# to epoch seconds and back for the offset to work
datetime = time.localtime(time.mktime(time.struct_time(
datetime = time.localtime(time.mktime(time.struct_time((
datetime.tm_year,
datetime.tm_mon,
datetime.tm_mday,
datetime.tm_hour + hours_ahead,
datetime.tm_min,
datetime.tm_sec,
-1, -1, -1)))
-1, -1, -1))))
# strftime() not available here
url = ('https://api.met.no/weatherapi/sunrise/2.0/.json?lat=' +
str(LATITUDE) + '&lon=' + str(LONGITUDE) +
Expand Down