diff --git a/examples/templates/index.html b/examples/templates/index.html
index 796e6a43..589cf76a 100644
--- a/examples/templates/index.html
+++ b/examples/templates/index.html
@@ -1,3 +1,2 @@
-{% set mydate = mydate|from_isodate -%}
-Today is {{ mydate.strftime('%Y-%m-%d') }}
+Today is {{ mydate|to_arrow|format_arrow('YYYY-MM-DD') }}
diff --git a/invenio_formatter/__init__.py b/invenio_formatter/__init__.py
index 1cf7def6..fa70f1b1 100644
--- a/invenio_formatter/__init__.py
+++ b/invenio_formatter/__init__.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# This file is part of Invenio.
-# Copyright (C) 2015 CERN.
+# Copyright (C) 2015, 2016, 2017 CERN.
#
# Invenio is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
@@ -36,8 +36,7 @@
.. code-block:: html
- {% set mydate = mydate|from_isodate -%}
- Today is {{ mydate.strftime('%Y-%m-%d') }}
+ Today is {{ mydate|to_arrow|format_arrow('YYYY-MM-DD') }}
Your book: {{ badge_svg('isbn','9780399547331')|safe }}
diff --git a/invenio_formatter/ext.py b/invenio_formatter/ext.py
index d2c8f565..61a1d828 100644
--- a/invenio_formatter/ext.py
+++ b/invenio_formatter/ext.py
@@ -29,7 +29,8 @@
from pkg_resources import DistributionNotFound, get_distribution
from . import config
-from .filters.datetime import from_isodate, from_isodatetime
+from .filters.datetime import format_arrow, from_isodate, from_isodatetime, \
+ to_arrow
from .views import create_badge_blueprint
@@ -55,6 +56,8 @@ def init_app(self, app):
app.jinja_env.filters.update(
from_isodate=from_isodate,
from_isodatetime=from_isodatetime,
+ to_arrow=to_arrow,
+ format_arrow=format_arrow,
)
if app.config['FORMATTER_BADGES_ENABLE']:
diff --git a/invenio_formatter/filters/datetime.py b/invenio_formatter/filters/datetime.py
index 06adba3f..2fb980e8 100644
--- a/invenio_formatter/filters/datetime.py
+++ b/invenio_formatter/filters/datetime.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# This file is part of Invenio.
-# Copyright (C) 2015, 2016 CERN.
+# Copyright (C) 2015, 2016, 2017 CERN.
#
# Invenio is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
@@ -53,3 +53,25 @@ def from_isodatetime(value, strict=False):
"""
if value or strict:
return arrow.get(value).datetime
+
+
+def format_arrow(value, format_string):
+ """Format an arrow datetime object.
+
+ :param value: The arrow datetime object.
+ :param format_string: The date format string
+ :returns: Returns a string representation of the given arrow datetime
+ object, formatted according to the given format string.
+
+ .. note::
+ Do not use this filter to format date/times presented to an end
+ user. Instead use ``datetimeformat`` or ``dateformat`` from
+ Invenio-I18N.
+ """
+ assert isinstance(value, arrow.Arrow)
+ return value.format(format_string)
+
+
+def to_arrow(value):
+ """Convert a Date object to an arrow datetime object."""
+ return arrow.get(value)
diff --git a/invenio_formatter/templates/invenio_formatter/macros/meta.html b/invenio_formatter/templates/invenio_formatter/macros/meta.html
index 50aad0b0..a4ea8fb3 100644
--- a/invenio_formatter/templates/invenio_formatter/macros/meta.html
+++ b/invenio_formatter/templates/invenio_formatter/macros/meta.html
@@ -1,6 +1,6 @@
{#
# This file is part of Invenio.
-# Copyright (C) 2015, 2016 CERN.
+# Copyright (C) 2015, 2016, 2017 CERN.
#
# Invenio is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
@@ -58,7 +58,7 @@
{%- endif %}
{%- if publication_date %}
-
+
{%- endif %}
{%- if doi %}