Documentation
¶
Index ¶
Constants ¶
const DefaultName = "UTC"
Variables ¶
This section is empty.
Functions ¶
func MustResolve ¶
MustResolve is a convenience helper for initialization code.
Types ¶
type BotLookup ¶ added in v1.0.2
type BotLookup interface {
GetBotByID(ctx context.Context, id pgtype.UUID) (sqlc.GetBotByIDRow, error)
GetUserByID(ctx context.Context, id pgtype.UUID) (sqlc.User, error)
}
BotLookup is the subset of database queries needed to derive a bot's effective timezone.
type Zone ¶ added in v1.0.2
Zone is a resolved timezone and where it comes from.
func ResolveBot ¶ added in v1.0.2
func ResolveBot(ctx context.Context, q BotLookup, botID pgtype.UUID, fallback *time.Location, logger *slog.Logger) Zone
ResolveBot returns a bot's effective timezone: the bot's own timezone, then its owner's, then fallback. A nil fallback means UTC.
Agent turns, the scheduler and the settings API must all use this, so a cron pattern fires at the time the agent meant and the time clients show. Who sent the current message never affects the result.
func ResolveBotWithInherited ¶ added in v1.0.2
func ResolveBotWithInherited(ctx context.Context, q BotLookup, botID pgtype.UUID, fallback *time.Location, logger *slog.Logger) (effective, inherited Zone)
ResolveBotWithInherited returns the bot's effective timezone together with the one it inherits when it has none of its own: its owner's, then fallback. Settings clients label the empty choice with the inherited one.