[improvement] Change date format behaviour on error
la-chemin opened this issue · comments
It would be better to return the original cell value when apply date format fails, instead of returning error message.
A XLS file is attached that would yield unwanted error message.
Below is my modifcation
func timeFmtFunc(f string) FmtFunc {
return func(x *Formatter, v interface{}) string {
t, ok := v.(time.Time)
if !ok {
fval, ok := convertToFloat64(v)
if !ok {
return v.(string) // convert it to string
}
t = x.ConvertToDate(fval)
}
//log.Println("formatting date", t, "with", f, "=", t.Format(f))
return t.Format(f)
}
}