String implements the Stringer interface.
()
| 131 | |
| 132 | // String implements the Stringer interface. |
| 133 | func (t *TimeTZ) String() string { |
| 134 | tTime := t.ToTime() |
| 135 | timeComponent := tTime.Format("15:04:05.999999") |
| 136 | // 24:00:00 gets returned as 00:00:00, which is incorrect. |
| 137 | if t.TimeOfDay == timeofday.Time2400 { |
| 138 | timeComponent = "24:00:00" |
| 139 | } |
| 140 | timeZoneComponent := tTime.Format("Z07:00:00") |
| 141 | // If it is UTC, .Format converts it to "Z". |
| 142 | // Fully expand this component. |
| 143 | if t.OffsetSecs == 0 { |
| 144 | timeZoneComponent = "+00:00:00" |
| 145 | } |
| 146 | // Go's time.Format functionality does not work for offsets which |
| 147 | // in the range -0s < offsetSecs < -60s, e.g. -22s offset prints as 00:00:-22. |
| 148 | // Manually correct for this. |
| 149 | if 0 < t.OffsetSecs && t.OffsetSecs < 60 { |
| 150 | timeZoneComponent = fmt.Sprintf("-00:00:%02d", t.OffsetSecs) |
| 151 | } |
| 152 | return timeComponent + timeZoneComponent |
| 153 | } |
| 154 | |
| 155 | // ToTime converts a DTimeTZ to a time.Time, corrected to the given location. |
| 156 | func (t *TimeTZ) ToTime() time.Time { |
no test coverage detected