Skip to content

game_time

game_time

Helpers for recurring Clash of Clans event windows (all times UTC).

Assumptions (these follow the game's long-standing schedule and may change):

  • Clan Games: 22nd 08:00 UTC to 28th 08:00 UTC each month.
  • Raid Weekend: Friday 07:00 UTC to Monday 07:00 UTC.
  • Legend League day: resets daily at 05:00 UTC.

League season boundaries have changed over time, so they are deliberately not computed here; use api.league_season() / league_season_id() instead.

clan_games_window

clan_games_window(
    now: datetime | None = None,
) -> tuple[datetime, datetime]

Start/end of the running Clan Games, or the next ones if none running.

Source code in cocapi/game_time.py
25
26
27
28
29
30
31
32
33
34
35
def clan_games_window(now: datetime | None = None) -> tuple[datetime, datetime]:
    """Start/end of the running Clan Games, or the next ones if none running."""
    t = _now(now)
    end_this = datetime(t.year, t.month, 28, 8, tzinfo=UTC)
    year, month = t.year, t.month
    if t >= end_this:
        year, month = (t.year + 1, 1) if t.month == 12 else (t.year, t.month + 1)
    return (
        datetime(year, month, 22, 8, tzinfo=UTC),
        datetime(year, month, 28, 8, tzinfo=UTC),
    )

raid_weekend_window

raid_weekend_window(
    now: datetime | None = None,
) -> tuple[datetime, datetime]

Start/end of the running raid weekend, or the next one if none running.

Source code in cocapi/game_time.py
38
39
40
41
42
43
44
45
46
47
def raid_weekend_window(now: datetime | None = None) -> tuple[datetime, datetime]:
    """Start/end of the running raid weekend, or the next one if none running."""
    t = _now(now)
    # Shift so the weekend ends at midnight Monday; weekday(): Mon=0
    shifted = t - timedelta(hours=7)
    end = (shifted + timedelta(days=7 - shifted.weekday())).replace(
        hour=7, minute=0, second=0, microsecond=0
    )
    start = end - timedelta(days=3)
    return start, end

legend_day_window

legend_day_window(
    now: datetime | None = None,
) -> tuple[datetime, datetime]

Start/end of the current Legend League day (05:00 UTC reset).

Source code in cocapi/game_time.py
62
63
64
65
66
67
68
def legend_day_window(now: datetime | None = None) -> tuple[datetime, datetime]:
    """Start/end of the current Legend League day (05:00 UTC reset)."""
    t = _now(now)
    start = t.replace(hour=5, minute=0, second=0, microsecond=0)
    if t < start:
        start -= timedelta(days=1)
    return start, start + timedelta(days=1)