FixedZone wraps time.FixedZone.
(hours, minutes, seconds int)
| 66 | |
| 67 | // FixedZone wraps time.FixedZone. |
| 68 | func (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 | } |
no test coverage detected