FixedZone wraps time.FixedZone.
(hours, minutes, seconds int)
| 80 | |
| 81 | // FixedZone wraps time.FixedZone. |
| 82 | func (z *zoneCache) FixedZone(hours, minutes, seconds int) *time.Location { |
| 83 | offset := (hours*60+minutes)*60 + seconds |
| 84 | z.mu.Lock() |
| 85 | ret, ok := z.mu.fixed[offset] |
| 86 | z.mu.Unlock() |
| 87 | |
| 88 | if !ok { |
| 89 | if minutes < 0 { |
| 90 | minutes *= -1 |
| 91 | } |
| 92 | if seconds < 0 { |
| 93 | seconds *= -1 |
| 94 | } |
| 95 | // Need a field width of 3 for the leading digit because we're |
| 96 | // forcing the sign to be printed and it counts as part of the field. |
| 97 | ret = time.FixedZone(fmt.Sprintf("%+03d%02d%02d", hours, minutes, seconds), offset) |
| 98 | z.mu.Lock() |
| 99 | z.mu.fixed[offset] = ret |
| 100 | z.mu.Unlock() |
| 101 | } |
| 102 | |
| 103 | return ret |
| 104 | } |