Skip to content
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

Update Thanksgiving Day app to dynamically calculate days till thanksgiving #2872

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -1,60 +1,64 @@
"""
Applet: Thanksgiving Day
Summary: Thanksgiving countdown
Description: Simple daily countdown until Thanksgiving Day holiday in the U.S.
Author: J. Alex Cooney
"""

load("encoding/base64.star", "base64")
load("math.star", "math")
load("render.star", "render")
load("time.star", "time")

# Load Turkey icon from base64 encoded data
TRK_ICON = base64.decode("""
R0lGODlhIAAgAPcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQEBAQMDAwUFBQkJCQ0NDRISEhYWFhoaGh0dHSAgICEhISIiIiMjIyQkJCUlJSYmJicnJygoKCkpKSoqKisrKywsLC0tLS4uLi8vLzAwMDIyLDQ0KjY2Jzg4JDk5IDo6HTs7Gzs7GTw8GDw8Fjw8FTw8FT09Fj09Fz09GT09Gj09HD4+Hz8/I0BAKkNCLEpGK1FKKllPKWFTJWhXIWxZHXBaGXNcFXZdEXleDHxgCH5gBX9hA4BhAoFhAYFhAYFhAIFhAIFhAIFhAIFhAIFhAIFhAIFhAIFhAIFhAIFhAIFhAIFiAIFiAIFiAIFiAIFiAIFiAIFiAIFiAIFiAIFiAIFiAIRbA4dVBolQCY1GDpE+EpQ4FpY0GpcxHpguIZoqJJopJ5orKpcxLpY1M5Q6OZJCQo9MTotXWYdmZ4VvdIR4eoKCgoODg4SEhIWFhYiIhIuLg46OgpCQgZKSgJSUf5WVfpeXfJiYe5mZepqaeZqaeJubd5ubd5ubd5ubdpubdpubdpubdpubdpubdpubdpycdpycdpycdpycdpycdpycd5ycd5ycd5yceJyceZ2de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in_location(timezone)

thanksgiving_year = now.year

thanksgiving_day = math.ceil(28 - (5 + now.year + now.year / 4 - now.year / 100 + now.year / 400) % 7)
if thanksgiving_year == 2024:
thanksgiving_day = 28
elif thanksgiving_year == 2025:
thanksgiving_day = 27

if 11 == now.month:
if 0 > thanksgiving_day - now.day:
thanksgiving_year = now.year + 1

if now.month > 11:
thanksgiving_year = now.year + 1

thanksgiving = time.time(year = thanksgiving_year, month = 11, day = thanksgiving_day, hour = 0, minute = 0, location = timezone)

print(thanksgiving)
days_til_thanksgiving = math.ceil(time.parse_duration(thanksgiving - now).seconds / 86400)
print(days_til_thanksgiving)

return render.Root(
delay = 1000,
child = render.Row(
# Row lays out its children horizontally
main_align = "space_evenly",
cross_align = "center",
expanded = True,
children = [
render.Image(src = TRK_ICON),
render.WrappedText(
content = "%s\ndays!" % days_til_thanksgiving,
font = "Dina_r400-6",
color = "#a60e00",
align = "center",
),
],
),
)
"""
Applet: Thanksgiving Day
Summary: Thanksgiving countdown
Description: Simple daily countdown until Thanksgiving Day holiday in the U.S.
Author: J. Alex Cooney
"""

load("encoding/base64.star", "base64")
load("math.star", "math")
load("render.star", "render")
load("time.star", "time")
load("humanize.star","humanize")

# Load Turkey icon from base64 encoded data
TRK_ICON = base64.decode("""
R0lGODlhIAAgAPcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQEBAQMDAwUFBQkJCQ0NDRISEhYWFhoaGh0dHSAgICEhISIiIiMjIyQkJCUlJSYmJicnJygoKCkpKSoqKisrKywsLC0tLS4uLi8vLzAwMDIyLDQ0KjY2Jzg4JDk5IDo6HTs7Gzs7GTw8GDw8Fjw8FTw8FT09Fj09Fz09GT09Gj09HD4+Hz8/I0BAKkNCLEpGK1FKKllPKWFTJWhXIWxZHXBaGXNcFXZdEXleDHxgCH5gBX9hA4BhAoFhAYFhAYFhAIFhAIFhAIFhAIF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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
""")

def main(config):

def getthanksgivingday(year):
nov30 = time.time(year = year,month = 11,day = 30,location = timezone)
day_of_week = humanize.day_of_week(nov30)
calc = day_of_week - 4
if calc > 0:
day = 30 - calc
else:
day = 30 - (calc + 7)

return day

timezone = config.get("timezone") or "America/New_York"
now = time.time(year = time.now().year,month = time.now().month,day = time.now().day,location = timezone)

day = getthanksgivingday(now.year)
thanksgiving_day = time.time(year = now.year,month = 11,day = day,location = timezone)
if now >= thanksgiving_day:
next_year = now.year + 1
day = getthanksgivingday(next_year)
thanksgiving_day = time.time(year = next_year,month = 11,day = day,location = timezone)

diff = thanksgiving_day - now
diff_days = abs(int(diff.hours / 24))
days_til_thanksgiving = diff_days


return render.Root(
delay = 1000,
child = render.Row(
# Row lays out its children horizontally
main_align = "space_evenly",
cross_align = "center",
expanded = True,
children = [
render.Image(src = TRK_ICON),
render.WrappedText(
content = "%s\ndays!" % days_til_thanksgiving,
font = "Dina_r400-6",
color = "#a60e00",
align = "center",
),
],
),
)
Loading