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

No timezone support for DatetimeCol #125

Open
satwell opened this issue Nov 20, 2019 · 0 comments
Open

No timezone support for DatetimeCol #125

satwell opened this issue Nov 20, 2019 · 0 comments

Comments

@satwell
Copy link

satwell commented Nov 20, 2019

I have datetime objects in UTC that I'd like to display in a local timezone with flask_table. I was expecting to be able to set BABEL_DEFAULT_TIMEZONE as mentioned in the Flask-Babel docs, but that doesn't have any effect. The underlying problem seems to be that DatetimeCol uses babel.dates.format_datetime rather than flask_babel.format_datetime. So timezone configuration from Flask-Babel isn't used.

It's not completely obvious that just switching to flask_babel.format_datetime is the best fix, because that would break anyone using DatetimeCol without initializing Flask-Babel. Maybe this isn't so bad, since BoolCol already depends on gettext from Flask-Babel?

Or maybe flask_table should automatically fall back to plain Babel if Flask-Babel isn't initialized?

A less invasive option would be to add an optional tzinfo keyword arg to DatetimeCol and pass that through to babel.dates.format_datetime. But this wouldn't be as nice as having proper Flask-Babel integration.

Happy to work on a pull request if you can provide some guidance.

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