MCPcopy Create free account
hub / github.com/dolthub/doltgresql / String

Method String

postgres/parser/timetz/timetz.go:170–194  ·  view source on GitHub ↗

String implements the Stringer interface.

()

Source from the content-addressed store, hash-verified

168
169// String implements the Stringer interface.
170func (t TimeTZ) String() string {
171 tTime := t.ToTime()
172 timeComponent := tTime.Format("15:04:05.999999")
173 // 24:00:00 gets returned as 00:00:00, which is incorrect.
174 if t.TimeOfDay == timeofday.Time2400 {
175 timeComponent = "24:00:00"
176 }
177 timeZoneComponent := tTime.Format("Z07")
178 // If it is UTC, .Format converts it to "Z".
179 // Fully expand this component.
180 if t.OffsetSecs == 0 {
181 timeZoneComponent = "+00"
182 } else if 0 < t.OffsetSecs && t.OffsetSecs < 60 {
183 // Go's time.Format functionality does not work for offsets which
184 // in the range -0s < offsetSecs < -60s, e.g. -22s offset prints as 00:00:-22.
185 // Manually correct for this.
186 timeZoneComponent = fmt.Sprintf("-00:00:%02d", t.OffsetSecs)
187 } else if t.OffsetSecs%60 != 0 {
188 timeZoneComponent = tTime.Format("Z07:00:00")
189 } else if t.OffsetSecs%3600 != 0 {
190 timeZoneComponent = tTime.Format("Z07:00")
191 }
192
193 return timeComponent + timeZoneComponent
194}
195
196// ToTime converts a DTimeTZ to a time.Time, corrected to the given location.
197func (t TimeTZ) ToTime() time.Time {

Callers

nothing calls this directly

Calls 2

ToTimeMethod · 0.95
FormatMethod · 0.65

Tested by

no test coverage detected