MCPcopy Create free account
hub / github.com/github/gh-aw / ConfigureProjectTimezone

Function ConfigureProjectTimezone

pkg/cli/project_timezone.go:20–48  ·  view source on GitHub ↗

ConfigureProjectTimezone applies the configured project timezone to CLI time rendering. Repo-level aw.json takes precedence over the enterprise default env var.

()

Source from the content-addressed store, hash-verified

18// ConfigureProjectTimezone applies the configured project timezone to CLI time rendering.
19// Repo-level aw.json takes precedence over the enterprise default env var.
20func ConfigureProjectTimezone() {
21 utcOffset := strings.TrimSpace(compilerenv.ResolveDefaultUTC(""))
22
23 gitRoot, err := findGitRootForProjectTimezone()
24 if err == nil {
25 if repoConfig, loadErr := loadRepoConfigForProjectTimezone(gitRoot); loadErr == nil && repoConfig != nil && strings.TrimSpace(repoConfig.UTC) != "" {
26 utcOffset = strings.TrimSpace(repoConfig.UTC)
27 } else if loadErr != nil {
28 projectTimezoneLog.Printf("Failed to load repo config for UTC offset resolution: %v", loadErr)
29 }
30 } else {
31 projectTimezoneLog.Printf("Failed to find git root for UTC offset resolution: %v", err)
32 }
33
34 if utcOffset == "" {
35 console.ResetTimeLocation()
36 return
37 }
38
39 location, err := workflow.ParseUTCOffsetLocation(utcOffset)
40 if err != nil {
41 projectTimezoneLog.Printf("Invalid configured UTC offset %q: %v", utcOffset, err)
42 console.ResetTimeLocation()
43 return
44 }
45
46 projectTimezoneLog.Printf("Configuring CLI rendered times to use UTC offset %q", utcOffset)
47 console.SetTimeLocation(location)
48}

Calls 5

ResolveDefaultUTCFunction · 0.92
ResetTimeLocationFunction · 0.92
ParseUTCOffsetLocationFunction · 0.92
SetTimeLocationFunction · 0.92
PrintfMethod · 0.45