You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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 usesbabel.dates.format_datetime
rather thanflask_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.
The text was updated successfully, but these errors were encountered: