From 02b84ff4ca747e3f1772fb42ed2d3246e257dd8a Mon Sep 17 00:00:00 2001 From: Jovial Joe Jayarson Date: Sat, 18 Jul 2020 08:49:37 +0530 Subject: [PATCH 1/2] fix: week streak changed to last 7 days from today --- main.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 075a944..24ae130 100644 --- a/main.py +++ b/main.py @@ -19,12 +19,11 @@ waka_key = os.getenv('INPUT_WAKATIME_API_KEY') ghtoken = os.getenv('INPUT_GH_TOKEN') def this_week(): - '''Returns current week span''' - week_number = datetime.date.today().isocalendar()[1] + '''Returns a week's streak''' month = datetime.date.today().strftime('%B') - week_start = datetime.datetime.today().day - datetime.datetime.today().weekday() - week_end = week_start + 5 - return f"Week #{week_number} : {month} {week_start} - {week_end}" + week_end = datetime.datetime.today().day - 1 + week_start = week_end - 7 + return f"Week : {month} {week_start} - {month} {week_end}" def make_graph(percent: float): '''Make progress graph from API graph''' From 49b64c7be8f61bd98dded38e42a0856803033cdc Mon Sep 17 00:00:00 2001 From: Jovial Joe Jayarson Date: Sat, 18 Jul 2020 09:31:13 +0530 Subject: [PATCH 2/2] fix: fixed month / year roll-over issue --- main.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index b23580f..2f22ef7 100644 --- a/main.py +++ b/main.py @@ -20,10 +20,9 @@ ghtoken = os.getenv('INPUT_GH_TOKEN') def this_week(): '''Returns a week's streak''' - month = datetime.date.today().strftime('%B') - week_end = datetime.datetime.today().day - 1 - week_start = week_end - 7 - return f"Week : {month} {week_start} - {month} {week_end}" + week_end = datetime.datetime.today() - datetime.timedelta(days=1) + week_start = week_end - datetime.timedelta(days=7) + return f"Week: {week_start.strftime('%d %B, %Y')} - {week_end.strftime('%d %B, %Y')}" def make_graph(percent: float): '''Make progress graph from API graph'''