From 1114547e57044bf4e9f4e0ee1e94e4aaa9b6e47d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 15 Jan 2026 19:57:24 +0000 Subject: [PATCH 1/3] Initial plan From f2b7f1755a444c5a43f683822a87cd83efe40a79 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 15 Jan 2026 20:09:55 +0000 Subject: [PATCH 2/3] Fix date display logic for cached vs fresh platform data - Change logic to check if data was fetched TODAY by comparing stored date with today's date - Previously: showed today's date for all platforms with mode='automatic' even if using cached data - Now: only shows today's date if the stored date matches today (was freshly fetched) - Cached/manual platforms correctly show their stored dates Co-authored-by: MishkatIT <125080003+MishkatIT@users.noreply.github.com> --- update_readme.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/update_readme.py b/update_readme.py index 2583b61..6e88729 100644 --- a/update_readme.py +++ b/update_readme.py @@ -273,16 +273,21 @@ def update_readme(stats, last_known_info=None, update_source=None): percentage = calculate_percentage(count_effective, total) # Pick date to display: - # - If freshly fetched with 'automatic' mode: use current date + # - If freshly fetched today (date matches today): use current date # - Otherwise: use last-known date (for manual updates or cached data) platform_mode = last_known_modes.get(platform, 'automatic') + raw_date = last_known_dates.get(platform) - if platform in stats and stats[platform] is not None and platform_mode == 'automatic': - # Freshly fetched automatically today - use current date + # Check if data was freshly fetched today by comparing dates + is_fresh_today = (platform in stats and + stats[platform] is not None and + raw_date == today_iso) + + if is_fresh_today: + # Freshly fetched today - use current date date_str = current_date else: # Using cached/manual value - show the cached date - raw_date = last_known_dates.get(platform) if raw_date: date_str = _format_human_date(raw_date) else: From eeb57fdd4b58a812a3282e5a96e11a746df3f0b7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 15 Jan 2026 20:11:46 +0000 Subject: [PATCH 3/3] Fix timezone consistency and workflow random delay - Use BDT timezone (UTC+6) consistently across all scripts - Fix random delay in workflow: was RANDOM % 1 (always 0), now RANDOM % 420 (0-7 minutes) - Ensures date consistency when running locally or in GitHub Actions - All date operations now use BDT timezone as intended Co-authored-by: MishkatIT <125080003+MishkatIT@users.noreply.github.com> --- .github/workflows/update-stats.yml | 2 +- manual_update.py | 9 ++++++--- update_stats.py | 6 ++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/update-stats.yml b/.github/workflows/update-stats.yml index f4ce9a3..967ca77 100644 --- a/.github/workflows/update-stats.yml +++ b/.github/workflows/update-stats.yml @@ -15,7 +15,7 @@ jobs: steps: - name: Random delay (0-7 minutes) run: | - RANDOM_SECONDS=$((RANDOM % 1)) + RANDOM_SECONDS=$((RANDOM % 420)) echo "Waiting for $RANDOM_SECONDS seconds to randomize execution time..." sleep $RANDOM_SECONDS diff --git a/manual_update.py b/manual_update.py index 8215586..f3a4db1 100644 --- a/manual_update.py +++ b/manual_update.py @@ -6,7 +6,7 @@ import json import os -from datetime import datetime +from datetime import datetime, timezone, timedelta def get_manual_stats(): @@ -59,7 +59,9 @@ def get_manual_stats(): def save_last_known_counts(stats): """Save the manually entered statistics as last known counts.""" - current_date = datetime.now().strftime('%Y-%m-%d') + # Use BDT timezone (UTC+6) for consistency + bdt_tz = timezone(timedelta(hours=6)) + current_date = datetime.now(bdt_tz).strftime('%Y-%m-%d') # Load existing data last_known = {'counts': {}, 'dates': {}, 'modes': {}} @@ -129,7 +131,8 @@ def main(): success = update_readme.update_readme(stats, last_known_info=last_known_info, update_source='manual') if success: print("\n✓ README.md has been updated successfully!") - print(f" Last updated: {datetime.now().strftime('%d %B %Y')}") + bdt_tz = timezone(timedelta(hours=6)) + print(f" Last updated: {datetime.now(bdt_tz).strftime('%d %B %Y')}") else: print("\n✗ Failed to update README.md") else: diff --git a/update_stats.py b/update_stats.py index 170a76d..daa8b09 100755 --- a/update_stats.py +++ b/update_stats.py @@ -34,7 +34,7 @@ import os from urllib.request import urlopen, Request from urllib.error import URLError, HTTPError -from datetime import datetime +from datetime import datetime, timezone, timedelta from bs4 import BeautifulSoup @@ -94,7 +94,9 @@ def _update_last_known(self, platform, count, mode=None): self.last_known_counts['modes'] = {} self.last_known_counts['counts'][platform] = count - self.last_known_counts['dates'][platform] = datetime.now().strftime('%Y-%m-%d') + # Use BDT timezone (UTC+6) for consistency with update_readme.py + bdt_tz = timezone(timedelta(hours=6)) + self.last_known_counts['dates'][platform] = datetime.now(bdt_tz).strftime('%Y-%m-%d') # Update the mode only if it is different from the existing one if mode is not None and self.last_known_counts['modes'].get(platform) != mode: