MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / FixedZone

Method FixedZone

pkg/util/timeutil/pgdate/zone_cache.go:68–90  ·  view source on GitHub ↗

FixedZone wraps time.FixedZone.

(hours, minutes, seconds int)

Source from the content-addressed store, hash-verified

66
67// FixedZone wraps time.FixedZone.
68func (z *zoneCache) FixedZone(hours, minutes, seconds int) *time.Location {
69 offset := (hours*60+minutes)*60 + seconds
70 z.mu.Lock()
71 ret, ok := z.mu.fixed[offset]
72 z.mu.Unlock()
73
74 if !ok {
75 if minutes < 0 {
76 minutes *= -1
77 }
78 if seconds < 0 {
79 seconds *= -1
80 }
81 // Need a field width of 3 for the leading digit because we're
82 // forcing the sign to be printed and it counts as part of the field.
83 ret = time.FixedZone(fmt.Sprintf("%+03d%02d%02d", hours, minutes, seconds), offset)
84 z.mu.Lock()
85 z.mu.fixed[offset] = ret
86 z.mu.Unlock()
87 }
88
89 return ret
90}

Callers 3

MakeTimeMethod · 0.80
MakeLocationMethod · 0.80

Calls 2

LockMethod · 0.80
UnlockMethod · 0.80

Tested by

no test coverage detected