diff --git a/config/config.example.json b/config/config.example.json index 77a8c0683..001d42939 100644 --- a/config/config.example.json +++ b/config/config.example.json @@ -2,6 +2,7 @@ "agents": { "defaults": { "workspace": "~/.picoclaw/workspace", + "timezone": "Asia/Makassar", "restrict_to_workspace": true, "model": "gpt4", "max_tokens": 8192, @@ -246,4 +247,4 @@ "host": "0.0.0.0", "port": 18790 } -} +} \ No newline at end of file diff --git a/pkg/config/config.go b/pkg/config/config.go index 036021e49..f08ea2747 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -6,6 +6,7 @@ import ( "os" "path/filepath" "sync/atomic" + "time" "github.com/caarlos0/env/v11" ) @@ -167,6 +168,7 @@ type SessionConfig struct { } type AgentDefaults struct { + Timezone string `json:"timezone,omitempty" env:"PICOCLAW_AGENTS_DEFAULTS_TIMEZONE"` Workspace string `json:"workspace" env:"PICOCLAW_AGENTS_DEFAULTS_WORKSPACE"` RestrictToWorkspace bool `json:"restrict_to_workspace" env:"PICOCLAW_AGENTS_DEFAULTS_RESTRICT_TO_WORKSPACE"` Provider string `json:"provider" env:"PICOCLAW_AGENTS_DEFAULTS_PROVIDER"` @@ -515,6 +517,15 @@ func LoadConfig(path string) (*Config, error) { return nil, err } + // Apply timezone from config — overrides process-wide default + if tz := cfg.Agents.Defaults.Timezone; tz != "" { + loc, err := time.LoadLocation(tz) + if err != nil { + return nil, fmt.Errorf("invalid timezone %q: %w", tz, err) + } + time.Local = loc + } + return cfg, nil }