Merge pull request #165 from sosedoff/fix/csv-timestamp-formatting

Specify cell timestamp layout for CSV export, #163
This commit is contained in:
Dan Sosedoff
2016-06-28 10:12:35 -05:00
committed by GitHub

View File

@@ -7,6 +7,7 @@ import (
"fmt" "fmt"
"reflect" "reflect"
"strconv" "strconv"
"time"
) )
type Row []interface{} type Row []interface{}
@@ -83,7 +84,12 @@ func (res *Result) CSV() []byte {
for i, item := range row { for i, item := range row {
if item != nil { if item != nil {
switch v := item.(type) {
case time.Time:
record[i] = v.Format("2006-01-02 15:04:05")
default:
record[i] = fmt.Sprintf("%v", item) record[i] = fmt.Sprintf("%v", item)
}
} else { } else {
record[i] = "" record[i] = ""
} }