Skip to content

Commit

Permalink
Update thanksgiving_day.star
Browse files Browse the repository at this point in the history
  • Loading branch information
savdagod authored Nov 9, 2024
1 parent 1f2e311 commit b0f8dae
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions apps/thanksgivingday/thanksgiving_day.star
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,32 @@ R0lGODlhIAAgAPcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
""")

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.now().in_location(timezone)
now = time.time(year = time.now().year,month = time.now().month,day = time.now().day,location = timezone)

nov30 = time.time(year = now.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)
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))
if now < thanksgiving_day:
days_til_thanksgiving = diff_days + 1
else:
days_til_thanksgiving = 365 - (diff_days + 1)
days_til_thanksgiving = diff_days


return render.Root(
delay = 1000,
Expand Down

0 comments on commit b0f8dae

Please sign in to comment.