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

Function ParseUTCOffsetLocation

pkg/workflow/utc_offset.go:46–66  ·  view source on GitHub ↗

ParseUTCOffsetLocation converts a numeric UTC offset to a fixed time.Location.

(raw string)

Source from the content-addressed store, hash-verified

44
45// ParseUTCOffsetLocation converts a numeric UTC offset to a fixed time.Location.
46func ParseUTCOffsetLocation(raw string) (*time.Location, error) {
47 normalized, err := NormalizeUTCOffset(raw)
48 if err != nil {
49 return nil, err
50 }
51
52 hours, err := strconv.Atoi(normalized[1:3])
53 if err != nil {
54 return nil, fmt.Errorf("invalid UTC offset format: %w", err)
55 }
56 minutes, err := strconv.Atoi(normalized[4:6])
57 if err != nil {
58 return nil, fmt.Errorf("invalid UTC offset format: %w", err)
59 }
60 offsetSeconds := hours*60*60 + minutes*60
61 if normalized[0] == '-' {
62 offsetSeconds = -offsetSeconds
63 }
64
65 return time.FixedZone("UTC"+normalized, offsetSeconds), nil
66}

Callers 1

ConfigureProjectTimezoneFunction · 0.92

Calls 2

NormalizeUTCOffsetFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected