Miscellaneous

Shared timestamp, season, date, and utility helpers.

Timestamp

struct clashy.Timestamp

Timestamp stores both the raw Clash API timestamp string and its parsed time.

RawTime

string

RawTime is the original API timestamp.

20060102T150405.000Z

Time

time.Time

Time is the parsed UTC time.

Time Delta

struct clashy.TimeDelta

TimeDelta represents an elapsed duration.

Season Window

struct clashy.SeasonWindow

SeasonID

string

SeasonID is the season identifier in YYYY-MM form.

StartTime

time.Time

StartTime is the inclusive season start time in UTC.

EndTime

time.Time

EndTime is the exclusive season end time in UTC.

Chat Language

struct clashy.ChatLanguage

ChatLanguage describes the preferred language configured for a clan.

ID

int json: id

ID is the language identifier.

Name

string json: name

Name is the language display name.

LanguageCode

string json: languageCode

LanguageCode is the language code returned by the API.

Timestamp Methods

clashy.Timestamp.After(other: Timestamp) -> bool

After reports whether this timestamp occurs after another timestamp.

Parameters:

other (Timestamp)

Return type:
bool

clashy.Timestamp.Before(other: Timestamp) -> bool

Before reports whether this timestamp occurs before another timestamp.

Parameters:

other (Timestamp)

Return type:
bool

clashy.Timestamp.SecondsUntil() -> int

SecondsUntil returns the number of whole seconds from now until the timestamp.

Return type:
int

clashy.Timestamp.UnmarshalJSON(data: []byte) -> error

UnmarshalJSON parses Clash API timestamp strings into Timestamp values.

Parameters:

data ([]byte)

Return type:
error

Functions

clashy.CorrectTag(tag: string) -> string

CorrectTag normalizes a Clash tag by trimming whitespace, uppercasing, replacing O with 0, removing invalid characters, and ensuring a leading #.

Parameters:

tag (string)

Return type:
string

clashy.FromTimestamp(raw: string) -> (time.Time, error)

FromTimestamp parses a Clash API timestamp in 20060102T150405.000Z format.

Parameters:

raw (string)

Return type:
time.Time error

clashy.GetSeasonID() -> string

GetSeasonID returns the current trophy season identifier in YYYY-MM form.

Return type:
string

clashy.GenSeasonDate(timestamp: time.Time) -> string

GenSeasonDate returns the trophy season identifier for timestamp.

Parameters:

timestamp (time.Time)

Return type:
string

clashy.GenLegendDate(timestamp: time.Time) -> string

GenLegendDate returns the legend-league day identifier for timestamp.

Legend days roll over at 05:00 UTC, so timestamps before that hour map to the previous calendar date.

Parameters:

timestamp (time.Time)

Return type:
string

clashy.GetSeasonStart(timestamp: time.Time) -> time.Time

GetSeasonStart returns the start time of the trophy season containing timestamp.

Parameters:

timestamp (time.Time)

Return type:
time.Time

clashy.GetSeasonEnd(timestamp: time.Time) -> time.Time

GetSeasonEnd returns the end time of the trophy season containing timestamp.

Parameters:

timestamp (time.Time)

Return type:
time.Time

clashy.GetSeason(timestamp: time.Time, forward: bool) -> SeasonWindow

GetSeason returns the trophy season window containing timestamp.

Passing a zero timestamp uses the current UTC time. Before the 2025 season calendar change, seasons end on the last Monday of the month at 05:00 UTC. From the September 2025 transition onward, seasons follow fixed 28 day windows.

Parameters:

timestamp (time.Time)

forward (bool)

Return type:
SeasonWindow

clashy.GetSeasonByID(seasonID: string) -> (SeasonWindow, error)

GetSeasonByID returns the trophy season window for a YYYY-MM season ID.

Parameters:

seasonID (string)

Return type:
SeasonWindow error

clashy.GetClanGamesStart(timestamp: time.Time) -> time.Time

GetClanGamesStart returns the Clan Games start time for the month containing timestamp, rolling forward after that month's Clan Games end.

Parameters:

timestamp (time.Time)

Return type:
time.Time

clashy.GetClanGamesEnd(timestamp: time.Time) -> time.Time

GetClanGamesEnd returns the Clan Games end time for the month containing timestamp, rolling forward after that month's Clan Games end.

Parameters:

timestamp (time.Time)

Return type:
time.Time

clashy.GetRaidWeekendStart(timestamp: time.Time) -> time.Time

GetRaidWeekendStart returns the start time for the raid weekend containing timestamp.

Parameters:

timestamp (time.Time)

Return type:
time.Time

clashy.GetRaidWeekendEnd(timestamp: time.Time) -> time.Time

GetRaidWeekendEnd returns the end time for the raid weekend containing timestamp.

Parameters:

timestamp (time.Time)

Return type:
time.Time

clashy.WithoutRateLimit(ctx: context.Context) -> context.Context

WithoutRateLimit returns a child context that bypasses the client's request limiter.

Use this for trusted internal calls where the caller is already controlling concurrency. It does not disable token rotation, caching, deadlines, or HTTP transport behavior.

Parameters:

ctx (context.Context)

Return type:
context.Context