getDateStyleOutputFormat returns the format layout for date/time values defined in the 'DateStyle' configuration parameter.
(ctx *sql.Context)
| 155 | |
| 156 | // getDateStyleOutputFormat returns the format layout for date/time values defined in the 'DateStyle' configuration parameter. |
| 157 | func 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 | |
| 179 | const ( |
| 180 | // ISO is ISO 8601, SQL standard |
no outgoing calls
no test coverage detected