跳到内容
🛠️ToolsShed

Time Capsule Calculator

计算时间胶囊可打开的时间,包含倒计时和进度跟踪。

快速设置开启日期

关于此工具

时间胶囊计算器帮助您跟踪从创建或密封胶囊的日期到可以打开胶囊的日期之间的时间流逝。无论您是为了未来发现而保存回忆、文件或纪念品,了解确切的等待时间都会增加期待感,并帮助您坚守时间表。该工具提供倒计时跟踪和可视化进度,让您一目了然地看到距离打开日期还剩多少时间。

要使用该计算器,只需输入时间胶囊将被打开的日期,该工具即会立即显示剩余的天数、周数、月数和年数。您可以通过设置不同的打开日期来追踪多个胶囊,并随时检查它们。进度条以可视化方式表示您在从今天到打开日期的旅程中已走了多远。

时间胶囊非常适合标记毕业、婚礼或重大人生事件等里程碑,此计算器使您能够轻松记住何时打开它们。无论您是创建包含给未来自己信件的个人胶囊,还是创建包含共享回忆的家庭胶囊,拥有倒计时都能使传统更有意义,并帮助确保您不会意外遗忘。

常见问题

代码实现

from datetime import date, timedelta
from dateutil.relativedelta import relativedelta

def time_capsule_info(seal_date: date, open_date: date) -> dict:
    """Calculate time capsule duration and milestones."""
    if open_date <= seal_date:
        raise ValueError("Open date must be after seal date")

    delta = relativedelta(open_date, seal_date)
    total_days = (open_date - seal_date).days
    days_remaining = (open_date - date.today()).days

    # Milestone dates
    milestones = {}
    for pct, label in [(25, "25%"), (50, "Halfway"), (75, "75%")]:
        days_offset = int(total_days * pct / 100)
        milestones[label] = seal_date + timedelta(days=days_offset)

    return {
        "seal_date": seal_date.isoformat(),
        "open_date": open_date.isoformat(),
        "duration_years": delta.years,
        "duration_months": delta.months,
        "duration_days": delta.days,
        "total_days": total_days,
        "days_remaining": max(0, days_remaining),
        "milestones": {k: v.isoformat() for k, v in milestones.items()},
        "decade": f"{(open_date.year // 10) * 10}s",
    }

info = time_capsule_info(date(2025, 1, 1), date(2035, 1, 1))
print(f"Duration: {info['duration_years']} years, {info['duration_months']} months")
print(f"Total days: {info['total_days']}")
print(f"Days remaining: {info['days_remaining']}")
print(f"Opening decade: the {info['decade']}")
for label, dt in info["milestones"].items():
    print(f"  {label}: {dt}")

Comments & Feedback

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