Skip to content

Commit 0253e4e

Browse files
authored
Update update_readme.py
1 parent 5910c6c commit 0253e4e

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

.github/scripts/update_readme.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,38 @@
11
import os
22
from datetime import datetime
33
import subprocess
4+
import pytz # Requires: pip install pytz
45

56
README_PATH = "README.md"
67

7-
# Count problems
8+
# Count only .java files in Easy, Medium, Hard
89
def count_problems():
910
count = 0
1011
for folder in ["Easy", "Medium", "Hard"]:
1112
if os.path.exists(folder):
1213
for file in os.listdir(folder):
13-
if os.path.isfile(os.path.join(folder, file)):
14+
if os.path.isfile(os.path.join(folder, file)) and file.endswith(".java"):
1415
count += 1
1516
return count
1617

17-
# Get last commit date
18+
# Get last commit date in human-readable IST format
1819
def last_updated():
1920
result = subprocess.run(
2021
["git", "log", "-1", "--format=%cd", "--date=iso"],
2122
capture_output=True,
2223
text=True
2324
)
24-
return result.stdout.strip()
25+
utc_time_str = result.stdout.strip()
26+
utc_time = datetime.fromisoformat(utc_time_str)
2527

28+
# Convert to IST
29+
ist = pytz.timezone("Asia/Kolkata")
30+
ist_time = utc_time.astimezone(ist)
31+
32+
# Return formatted date
33+
return ist_time.strftime("%d %b %Y, %I:%M %p IST")
34+
35+
# Update README.md with the latest values
2636
def update_readme():
2737
with open(README_PATH, "r", encoding="utf-8") as f:
2838
content = f.read()

0 commit comments

Comments
 (0)