aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pyaggr3g470r/__init__.py9
-rw-r--r--pyaggr3g470r/templates/home.html4
-rw-r--r--pyaggr3g470r/templates/management.html4
-rw-r--r--pyaggr3g470r/views.py6
4 files changed, 17 insertions, 6 deletions
diff --git a/pyaggr3g470r/__init__.py b/pyaggr3g470r/__init__.py
index da978128..708598b1 100644
--- a/pyaggr3g470r/__init__.py
+++ b/pyaggr3g470r/__init__.py
@@ -21,6 +21,15 @@ db = SQLAlchemy(app)
ALLOWED_EXTENSIONS = set(['xml', 'opml'])
+from flask.ext.babel import format_datetime
+app.jinja_env.filters['datetime'] = format_datetime
+
+TIME_ZONE = {
+ "en": "US/Eastern",
+ "fr": "Europe/Paris"
+ }
+
+
def allowed_file(filename):
"""
Check if the uploaded file is allowed.
diff --git a/pyaggr3g470r/templates/home.html b/pyaggr3g470r/templates/home.html
index 43fdbb97..565614fe 100644
--- a/pyaggr3g470r/templates/home.html
+++ b/pyaggr3g470r/templates/home.html
@@ -24,7 +24,7 @@
{% if feed.articles[n].readed %}<h3>{% else %}<h1>{% endif %}
<a href="/article/{{ feed.articles[n].id }}">{{ feed.articles[n].title|safe }}</a>
{% if feed.articles[n].readed %}</h3>{% else %}</h1>{% endif %}
- <h6>{{ feed.articles[n].date.strftime('%A, %d %B %Y') }}</h6>
+ <h6>{{ feed.articles[n].date | datetime }}</h6>
</div>
{% endfor %}
</div>
@@ -36,7 +36,7 @@
{% if feed.articles[n].readed %}<h3>{% else %}<h1>{% endif %}
<a href="/article/{{ feed.articles[n].id }}">{{ feed.articles[n].title|safe }}</a>
{% if feed.articles[n].readed %}</h3>{% else %}</h1>{% endif %}
- <h6>{{ feed.articles[n].date.strftime('%A, %d %B %Y') }}</h6>
+ <h6>{{ feed.articles[n].date | datetime }}</h6>
</div>
{% endfor %}
</div>
diff --git a/pyaggr3g470r/templates/management.html b/pyaggr3g470r/templates/management.html
index b37653c4..f68978b2 100644
--- a/pyaggr3g470r/templates/management.html
+++ b/pyaggr3g470r/templates/management.html
@@ -14,8 +14,8 @@
<div class="row">
<div class="col-md-6">
<p>{{ _('Update your') }} <a href="/profile/">{{ _('profile') }}</a>.</p>
- <p>{{ _('Member since') }} {{ user.date_created.strftime('%A, %d %B %Y') }}.</p>
- <p>{{ _('Last seen:') }} {{ user.last_seen.strftime('%A, %d %B %Y at %H:%M:%S') }}.</p>
+ <p>{{ _('Member since') }} {{ user.date_created | datetime }}.</p>
+ <p>{{ _('Last seen:') }} {{ user.last_seen | datetime }}.</p>
</div>
<div class="col-md-6">
<img src="{{ user.email | gravatar }}" />
diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py
index f9a44228..1fb1658c 100644
--- a/pyaggr3g470r/views.py
+++ b/pyaggr3g470r/views.py
@@ -42,7 +42,7 @@ import export
if not conf.ON_HEROKU:
import search as fastsearch
from forms import SigninForm, AddFeedForm, ProfileForm
-from pyaggr3g470r import app, db, allowed_file, babel
+from pyaggr3g470r import app, db, allowed_file, babel, TIME_ZONE
from pyaggr3g470r.models import User, Feed, Article, Role
from pyaggr3g470r.decorators import feed_access_required
@@ -112,7 +112,6 @@ def redirect_url(default='home'):
request.referrer or \
url_for(default)
-
@babel.localeselector
def get_locale():
"""
@@ -121,6 +120,9 @@ def get_locale():
"""
return request.accept_languages.best_match(conf.LANGUAGES.keys())
+@babel.timezoneselector
+def get_timezone():
+ return TIME_ZONE[get_locale()]
#
# Views.
bgstack15