Skip to content

Commit fd4498a

Browse files
authored
Merge pull request #14 from TristanStreich/master
Update Day Based on Eastern Timezone
2 parents 4da8f70 + 58f1ca3 commit fd4498a

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
FROM python:3.8-alpine
22

33
RUN pip install requests
4+
RUN pip install pytz
5+
46

57
ADD entrypoint.sh /entrypoint.sh
68
ADD aoc-badges.py /aoc-badges.py

aoc-badges.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import os
44
import re
55
import io
6-
from datetime import date, timedelta
6+
from datetime import date, timedelta, datetime
7+
import pytz
78

89
# environment variables
910
year = os.getenv('INPUT_YEAR')
@@ -47,11 +48,16 @@
4748
if '2' in data['members'][userid]['completion_day_level'][day]:
4849
days_completed += 1
4950

50-
# current day
51-
today = date.today() - timedelta(hours=5)
52-
if today < date(year, 12, 1):
51+
# Set the timezone to New York
52+
new_york_tz = pytz.timezone('America/New_York')
53+
54+
# Get the current time in New York
55+
today = datetime.now(new_york_tz).date()
56+
57+
# Your existing logic to determine the day
58+
if today < datetime(year, 12, 1, tzinfo=new_york_tz).date():
5359
day = 0
54-
elif today > date(year, 12, 31):
60+
elif today > datetime(year, 12, 31, tzinfo=new_york_tz).date():
5561
day = 24
5662
else:
5763
day = today.day

0 commit comments

Comments
 (0)