Skip to content

No timezone support for DatetimeCol #125

@satwell

Description

@satwell

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions