본문으로 건너뛰기
🛠️ToolsShed

Next Birthday Calculator

다음 생일까지의 일수, 현재 나이, 요일을 계산합니다.

이 도구 소개

생일은 매년 축하하는 특별한 날이지만, 다음 생일까지의 정확한 일수를 파악하는 것은 특별한 행사를 계획하거나 소중한 사람들에게 알리거나 단순히 다음 축하가 얼마나 남았는지 알고 싶을 때 놀랍도록 유용할 수 있습니다. 이 Next Birthday Calculator는 생년월일을 기반으로 다음 생일까지 남은 일수를 즉시 계산하고, 현재 나이를 표시하며, 다음 생일이 무슨 요일인지까지 알려줍니다.

이 도구는 매우 간단하게 사용할 수 있습니다. 생년월일을 입력하면 카운트다운 일수, 정확한 나이(년 단위), 그리고 다음 생일의 요일명이 즉시 표시됩니다. 생일이 언제이든 상관없이, 몇 개월 앞이든 몇 주 앞이든 작동하여 깜짝 생일 파티 계획, 생일 관련 행사 일정 조율, 사전 알림 설정에 완벽합니다.

자주 묻는 질문

코드 구현

from datetime import date

def next_birthday_info(birth_date: date, today: date = None) -> dict:
    """Calculate days until next birthday, current age, and day of week."""
    if today is None:
        today = date.today()

    age = today.year - birth_date.year
    # Check if birthday already happened this year
    had_birthday = (today.month, today.day) >= (birth_date.month, birth_date.day)
    if not had_birthday:
        age -= 1

    # Next birthday
    next_year = today.year if not had_birthday else today.year + 1
    try:
        next_bday = date(next_year, birth_date.month, birth_date.day)
    except ValueError:  # Feb 29 on non-leap year
        next_bday = date(next_year, 3, 1)

    days_until = (next_bday - today).days
    day_of_week = next_bday.strftime("%A")

    return {
        "current_age": age,
        "next_birthday": next_bday.isoformat(),
        "days_until": days_until,
        "day_of_week": day_of_week,
        "is_today": days_until == 0,
    }

info = next_birthday_info(date(1990, 7, 15))
print(f"Age: {info['current_age']}")
print(f"Next birthday: {info['next_birthday']} ({info['day_of_week']})")
print(f"Days until: {info['days_until']}")

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.