Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improvement] Change date format behaviour on error #16

Open
la-chemin opened this issue Sep 26, 2023 · 0 comments
Open

[improvement] Change date format behaviour on error #16

la-chemin opened this issue Sep 26, 2023 · 0 comments

Comments

@la-chemin
Copy link

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.

testFile.xls

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)
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant