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

Function getDateStyleOutputFormat

server/functions/timestamp.go:157–177  ·  view source on GitHub ↗

getDateStyleOutputFormat returns the format layout for date/time values defined in the 'DateStyle' configuration parameter.

(ctx *sql.Context)

Source from the content-addressed store, hash-verified

155
156// getDateStyleOutputFormat returns the format layout for date/time values defined in the 'DateStyle' configuration parameter.
157func getDateStyleOutputFormat(ctx *sql.Context) string {
158 // TODO: this is expensive, we should only do this once for each query
159 format := DateStyleISO // default
160 if ctx == nil {
161 return format
162 }
163
164 val, err := ctx.GetSessionVariable(ctx, "datestyle")
165 if err != nil {
166 return format
167 }
168
169 values := strings.Split(strings.ReplaceAll(val.(string), " ", ""), ",")
170 for _, value := range values {
171 switch value {
172 case DateStyleISO, DateStyleSQL, DateStylePostgres, DateStyleGerman:
173 return value
174 }
175 }
176 return format
177}
178
179const (
180 // ISO is ISO 8601, SQL standard

Callers 1

getLayoutStringFormatFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected