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

Method Format

postgres/parser/pgdate/pgdate.go:170–189  ·  view source on GitHub ↗

Format formats d as a string.

(buf *bytes.Buffer)

Source from the content-addressed store, hash-verified

168
169// Format formats d as a string.
170func (d Date) Format(buf *bytes.Buffer) {
171 switch d.days {
172 case math.MinInt32:
173 buf.WriteString("-infinity")
174 case math.MaxInt32:
175 buf.WriteString("infinity")
176 default:
177 // ToTime only returns an error on infinity, which was already checked above.
178 t, _ := d.ToTime()
179 year, month, day := t.Date()
180 bc := year <= 0
181 if bc {
182 year = -year + 1
183 }
184 fmt.Fprintf(buf, "%04d-%02d-%02d", year, month, day)
185 if bc {
186 buf.WriteString(" BC")
187 }
188 }
189}
190
191func (d Date) String() string {
192 var buf bytes.Buffer

Callers 1

StringMethod · 0.95

Calls 2

ToTimeMethod · 0.95
WriteStringMethod · 0.80

Tested by

no test coverage detected