func NewDateConv(colinfo schema.Columns) (dfmth *DateFmtHandle) { dfmth = &DateFmtHandle{make([]DateFmtFunc, len(colinfo))} for idx, ci := range colinfo { if ci.Datefmt == "" { dfmth.fmtf[idx] = func(i string) string { return i } } else { var df string = ci.Datefmt dfmth.fmtf[idx] = func(i string) (o string) { t, _ := datefmt.Strptime(df, i) o, _ = datefmt.Strftime(StdDateFmt, t) return } } } return }
// Strptime converts a string to a time using some C-style format. func Strptime(time, fmt string) (time.Time, error) { // TODO(knz) The `datefmt` package uses C's `strptime` which doesn't // know about microseconds. We may want to change to an // implementation that does this better. return datefmt.Strptime(fmt, time) }