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

Method String

pkg/util/timetz/timetz.go:133–153  ·  view source on GitHub ↗

String implements the Stringer interface.

()

Source from the content-addressed store, hash-verified

131
132// String implements the Stringer interface.
133func (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.
156func (t *TimeTZ) ToTime() time.Time {

Callers 2

prettyPrintFirstValueFunction · 0.95
PrettyPrintValueEncodedFunction · 0.95

Calls 2

ToTimeMethod · 0.95
FormatMethod · 0.65

Tested by

no test coverage detected