From 98c3a23c65d9545cdd7f481a00905ebcd502ef7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 23 Jan 2015 11:38:09 +0100 Subject: [PATCH] Use localizeddate to format date refs #272 --- Resources/views/History/form.html.twig | 2 +- Resources/views/History/list.html.twig | 4 ++-- Resources/views/Person/create_review.html.twig | 6 +++--- Resources/views/Person/list.html.twig | 2 +- Resources/views/Person/view.html.twig | 9 +++++++-- Resources/views/layout.html.twig | 2 +- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Resources/views/History/form.html.twig b/Resources/views/History/form.html.twig index 440a21777..0fdaa7c9c 100644 --- a/Resources/views/History/form.html.twig +++ b/Resources/views/History/form.html.twig @@ -10,7 +10,7 @@ {{ form_start(form) }} {{ 'Last opening since %last_opening%'|trans( - { '%last_opening%' : history.dateOpening|date(date_format) }) }} + { '%last_opening%' : history.dateOpening|localizeddate('long', 'none', app.request.locale) }) }} {% if form.dateClosing is defined %} {{ form_row(form.dateClosing, {'label' : 'Closing date'} ) }} diff --git a/Resources/views/History/list.html.twig b/Resources/views/History/list.html.twig index ab33bf14a..8f36d951d 100644 --- a/Resources/views/History/list.html.twig +++ b/Resources/views/History/list.html.twig @@ -18,13 +18,13 @@ {% set i = 0 %} {% for history in histories %} - {{ history.dateOpening|date(date_format) }} + {{ history.dateOpening|localizeddate('long', 'none', app.request.locale) }} {% spaceless %} {% if history.isOpen %} {{ 'Still open'|trans }} {% else %} - {{ history.dateClosing|date(date_format) }} + {{ history.dateClosing|localizeddate('long', 'none', app.request.locale) }} {% endif %} {% endspaceless %} diff --git a/Resources/views/Person/create_review.html.twig b/Resources/views/Person/create_review.html.twig index ce03f3b4c..159f6e55a 100644 --- a/Resources/views/Person/create_review.html.twig +++ b/Resources/views/Person/create_review.html.twig @@ -38,7 +38,7 @@ {% endspaceless %} - {{ person.dateOfBirth|date(date_format) }} + {{ person.dateOfBirth|localizeddate('long', 'none', app.request.locale) }} {% if person.nationality is not null %}{{ person.nationality.name|localize_translatable_string }}{% else %}{{ 'Without nationality'|trans }}{% endif %} @@ -61,13 +61,13 @@
{{ lastName }}
{{ 'Date of birth'|trans }}
-
{{ dateOfBirth|date(date_format)|default( 'Unknown date of birth'|trans ) }}
+
{{ dateOfBirth|localizeddate('medium', 'none', app.request.locale)|default( 'Unknown date of birth'|trans ) }}
{{ 'Gender'|trans }}
{{ genre|trans }}
{{ 'Creation date'|trans }}
-
{{ creation_date|date(date_format) }}
+
{{ creation_date|localizeddate('medium', 'none', app.request.locale) }}
{{ form_rest(form) }} diff --git a/Resources/views/Person/list.html.twig b/Resources/views/Person/list.html.twig index ee3e8f6cb..c90bc348c 100644 --- a/Resources/views/Person/list.html.twig +++ b/Resources/views/Person/list.html.twig @@ -42,7 +42,7 @@ - {{person.dateOfBirth.format(date_format)|default( 'Unknown date of birth'|trans )}} + {% if person.dateOfBirth is not null %}{{person.dateOfBirth|localizeddate('long', 'none', app.request.locale) }}{% else %}{{ 'Unknown date of birth'|trans }}{% endif %} {% if person.nationality is not null %} diff --git a/Resources/views/Person/view.html.twig b/Resources/views/Person/view.html.twig index b8afa7436..56896403b 100644 --- a/Resources/views/Person/view.html.twig +++ b/Resources/views/Person/view.html.twig @@ -58,8 +58,13 @@ This view should receive those arguments:
{{ 'Date of birth'|trans }}
-
{{ person.dateOfBirth.format(date_format) - |default( 'Unknown date of birth'|trans ) }}
+
+ {%- if person.dateOfBirth is not null -%} + {{ person.dateOfBirth|localizeddate('long', 'none') }} + {%- else -%} + {{ 'Unknown date of birth'|trans }} + {%- endif -%} +
{{ 'Place of birth'|trans }}
diff --git a/Resources/views/layout.html.twig b/Resources/views/layout.html.twig index 57eae1c71..41c330f30 100644 --- a/Resources/views/layout.html.twig +++ b/Resources/views/layout.html.twig @@ -42,7 +42,7 @@ person.genre)|trans }} {% else %} {% transchoice person.genreNumeric - with {'%date%' : person.dateOfBirth.format('d-m-Y')} %} + with {'%date%' : person.dateOfBirth|localizeddate('long', 'none')} %} {0} Born the %date% | {1} Born the %date% {% endtranschoice %} {% endif %}