Skip to content

Commit 0ba3307

Browse files
authored
SlotMachineClock: Support for different timezones (#3022)
* Create README.md * Create .gitignore * Create Apache License 2.0 * Implemented full functionality All animations for all slots are in, they all work for all times. Fully functioning app. * Update README.md * Create manifest.yaml * Update manifest.yaml * Update manifest.yaml * Update manifest.yaml * Update manifest.yaml * Update slotMachineClock.star Fixed lint issues when attempting to pull * Update slotMachineClock.star Fixed more lint issues * Update slotMachineClock.star Lint issues might have been caused with line endings * Lint fixes * Support for timezones * Used suggested timezone code
1 parent ba61b4d commit 0ba3307

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

apps/slotMachineClock/slotMachineClock.star

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ MINUTE_IS_NINE = base64.decode("iVBORw0KGgoAAAANSUhEUgAAAA0AAAAgCAYAAADJ2fKUAAAA
7979

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

83-
current_time = get_current_time_as_tuple()
84+
current_time = get_current_time_as_tuple(timezone)
8485
ten_hour_value = current_time[0]
8586
hour_value = current_time[1]
8687
ten_minute_value = current_time[2]
@@ -183,8 +184,9 @@ def get_schema():
183184
],
184185
) #returns the time as a tuple of each digit
185186

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

0 commit comments

Comments
 (0)