Skip to content

Add current date display to Christmas app with network caching#8

Merged
atarukun merged 3 commits intochristmasfrom
copilot/add-date-printout-feature
Oct 30, 2025
Merged

Add current date display to Christmas app with network caching#8
atarukun merged 3 commits intochristmasfrom
copilot/add-date-printout-feature

Conversation

Copy link

Copilot AI commented Oct 30, 2025

Adds today's date display at the bottom of the Christmas countdown app in DD MMM YYYY format (e.g., "30 Oct 2025"). Leverages existing network time API with 1-hour cache.

Changes

  • Date formatting: Added MONTH_NAMES array and format_date() helper for DD MMM YYYY output with zero-padded days
  • Date retrieval: Added get_current_date_string() that uses existing fetch_current_date() cache, falls back to time.localtime() on network failure
  • Display: Renders centered date at y=105 using small_font for consistency with other labels

Implementation

# Month names (short format)
MONTH_NAMES = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", 
               "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]

def format_date(year, month, day):
    """Format date as DD MMM YYYY (e.g., 30 Oct 2025)"""
    month_name = MONTH_NAMES[month - 1] if 1 <= month <= 12 else "???"
    return f"{day:02d} {month_name} {year}"

def get_current_date_string():
    """Get current date formatted as DD MMM YYYY"""
    fetched_date = fetch_current_date()  # Uses 1-hour cache
    if fetched_date:
        return format_date(*fetched_date)
    try:
        now = time.localtime()
        return format_date(now[0], now[1], now[2])
    except Exception:
        return None

Network caching already implemented via _cached_time with FETCH_INTERVAL = 60 * 60 * 1000 (1 hour).

Original prompt

Please add at the bottom of the Christmas app, a small printout of today's date in the DD MMM YYYY format. The month should be short names, such as Jan, Feb, Mar, etc...

The network call to determine the date should also be cached locally, so we don't have to keep calling the network every time the panel refreshes.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI self-assigned this Oct 30, 2025
Copilot AI and others added 2 commits October 30, 2025 16:16
Co-authored-by: atarukun <6511495+atarukun@users.noreply.github.com>
Co-authored-by: atarukun <6511495+atarukun@users.noreply.github.com>
Copilot AI changed the title [WIP] Add printout of today's date in Christmas app Add current date display to Christmas app with network caching Oct 30, 2025
Copilot AI requested a review from atarukun October 30, 2025 16:21
@atarukun atarukun marked this pull request as ready for review October 30, 2025 16:21
Copilot AI review requested due to automatic review settings October 30, 2025 16:21
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a current date display feature to the Christmas countdown app. The date is shown at the bottom of the screen in DD MMM YYYY format (e.g., "30 Oct 2025").

Key changes:

  • Added date formatting utilities (MONTH_NAMES constant, format_date, and get_current_date_string functions)
  • Integrated the formatted date display into the update() function
  • Reuses existing date fetching logic from fetch_current_date() with fallback to local time

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Owner

@atarukun atarukun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@atarukun atarukun merged commit c2b7be5 into christmas Oct 30, 2025
6 checks passed
@atarukun atarukun deleted the copilot/add-date-printout-feature branch October 30, 2025 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants