timezone

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultName = "UTC"

Variables

This section is empty.

Functions

func MustResolve

func MustResolve(name string) *time.Location

MustResolve is a convenience helper for initialization code.

func Resolve

func Resolve(name string) (*time.Location, string, error)

Resolve returns a loadable time.Location for the provided timezone name. Empty names fall back to UTC so the rest of the system stays deterministic.

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 Source added in v1.0.2

type Source string

Source says where a bot's timezone comes from.

const (
	SourceBot    Source = "bot"
	SourceOwner  Source = "owner"
	SourceSystem Source = "system"
)

type Zone added in v1.0.2

type Zone struct {
	Location *time.Location
	Name     string
	Source   Source
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL