Skip to content

Commit

Permalink
Fix timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyEye-FAST committed Jan 27, 2024
1 parent 24b3f77 commit e375221
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from wtforms import StringField, SubmitField

from flask_babel import Babel, lazy_gettext, format_date
from babel.dates import get_timezone_name, get_timezone
from babel.dates import get_timezone_name

from base import data, is_valid_key, get_translation

Expand All @@ -25,7 +25,7 @@ def get_locale():
return request.accept_languages.best_match(["zh", "en"])


babel = Babel(flask_app, locale_selector=get_locale, timezone_selector=get_timezone)
babel = Babel(flask_app, locale_selector=get_locale)


class QueryForm(FlaskForm):
Expand All @@ -38,6 +38,8 @@ class QueryForm(FlaskForm):
@flask_app.route("/", methods=["GET", "POST"])
def index():
"""主页面"""
timezone = request.headers.get("Time-Zone")

form = QueryForm()

query_str = form.source_string.data
Expand All @@ -64,8 +66,8 @@ def index():
keys=keys,
translation=selected_translation,
date_str=date.today(),
date_str_t=format_date(date.today()),
timezone_str=get_timezone_name(get_timezone(), locale=get_locale()),
date_str_t=format_date(date.today(), "long"),
timezone_str=get_timezone_name(timezone, locale=get_locale()),
)


Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Babel==2.14.0
Flask==3.0.1
flask_babel==4.0.0
flask_wtf==1.2.1
Expand Down

0 comments on commit e375221

Please sign in to comment.