Skip to content

SlotMachineClock: Support for different timezones #3022

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 19 commits into from
Apr 24, 2025
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: 5 additions & 3 deletions apps/slotMachineClock/slotMachineClock.star
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ MINUTE_IS_NINE = base64.decode("iVBORw0KGgoAAAANSUhEUgAAAA0AAAAgCAYAAADJ2fKUAAAA

def main(config):
speed = int(config.str("speed", 2)) #takes user input equating to how many loops to spin before displaying time
timezone = config.get("$tz", "America/New_York")

current_time = get_current_time_as_tuple()
current_time = get_current_time_as_tuple(timezone)
ten_hour_value = current_time[0]
hour_value = current_time[1]
ten_minute_value = current_time[2]
Expand Down Expand Up @@ -183,8 +184,9 @@ def get_schema():
],
) #returns the time as a tuple of each digit

def get_current_time_as_tuple():
total_hour = list(time.now().format("3:04").partition(":")[0].elems()) #gets the hour as a list of single character strings
def get_current_time_as_tuple(timezone):
tz_now = time.now().in_location(timezone)
total_hour = list(tz_now.format("3:04").partition(":")[0].elems()) #gets the hour as a list of single character strings
ten_hour_value = 0
hour_value = int(total_hour[0])
if (len(total_hour) == 2): #if theres a ten's digit for hours, set ten_hour to 1 and fix hour
Expand Down