Use localizeddate to format date

refs #272
This commit is contained in:
Julien Fastré 2015-01-23 11:38:09 +01:00
parent e9be284c03
commit 98c3a23c65
6 changed files with 15 additions and 10 deletions

View File

@ -10,7 +10,7 @@
{{ form_start(form) }} {{ form_start(form) }}
{{ 'Last opening since %last_opening%'|trans( {{ '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 %} {% if form.dateClosing is defined %}
{{ form_row(form.dateClosing, {'label' : 'Closing date'} ) }} {{ form_row(form.dateClosing, {'label' : 'Closing date'} ) }}

View File

@ -18,13 +18,13 @@
{% set i = 0 %} {% set i = 0 %}
{% for history in histories %} {% for history in histories %}
<tr class="{% if i is not even %}striped{% endif %}"> <tr class="{% if i is not even %}striped{% endif %}">
<td>{{ history.dateOpening|date(date_format) }}</td> <td>{{ history.dateOpening|localizeddate('long', 'none', app.request.locale) }}</td>
<td>{% spaceless %} <td>{% spaceless %}
{% if history.isOpen %} {% if history.isOpen %}
{{ 'Still open'|trans }} {{ 'Still open'|trans }}
{% else %} {% else %}
{{ history.dateClosing|date(date_format) }} {{ history.dateClosing|localizeddate('long', 'none', app.request.locale) }}
{% endif %} {% endif %}
{% endspaceless %}</td> {% endspaceless %}</td>

View File

@ -38,7 +38,7 @@
{% endspaceless %} {% endspaceless %}
</a> </a>
</td> </td>
<td>{{ person.dateOfBirth|date(date_format) }}</td> <td>{{ person.dateOfBirth|localizeddate('long', 'none', app.request.locale) }}</td>
<td>{% if person.nationality is not null %}{{ person.nationality.name|localize_translatable_string }}{% else %}{{ 'Without nationality'|trans }}{% endif %} <td>{% if person.nationality is not null %}{{ person.nationality.name|localize_translatable_string }}{% else %}{{ 'Without nationality'|trans }}{% endif %}
</tr> </tr>
@ -61,13 +61,13 @@
<dd>{{ lastName }}</dd> <dd>{{ lastName }}</dd>
<dt>{{ 'Date of birth'|trans }}</dt> <dt>{{ 'Date of birth'|trans }}</dt>
<dd>{{ dateOfBirth|date(date_format)|default( 'Unknown date of birth'|trans ) }}</dd> <dd>{{ dateOfBirth|localizeddate('medium', 'none', app.request.locale)|default( 'Unknown date of birth'|trans ) }}</dd>
<dt>{{ 'Gender'|trans }}</dt> <dt>{{ 'Gender'|trans }}</dt>
<dd>{{ genre|trans }}</dd> <dd>{{ genre|trans }}</dd>
<dt>{{ 'Creation date'|trans }}</dt> <dt>{{ 'Creation date'|trans }}</dt>
<dd>{{ creation_date|date(date_format) }}</dd> <dd>{{ creation_date|localizeddate('medium', 'none', app.request.locale) }}</dd>
</dl> </dl>
{{ form_rest(form) }} {{ form_rest(form) }}

View File

@ -42,7 +42,7 @@
</a> </a>
</td> </td>
<td> <td>
<span class="personDateOfBirth">{{person.dateOfBirth.format(date_format)|default( 'Unknown date of birth'|trans )}}</span> <span class="personDateOfBirth">{% if person.dateOfBirth is not null %}{{person.dateOfBirth|localizeddate('long', 'none', app.request.locale) }}{% else %}{{ 'Unknown date of birth'|trans }}{% endif %}</span>
</td> </td>
<td> <td>
{% if person.nationality is not null %} {% if person.nationality is not null %}

View File

@ -58,8 +58,13 @@ This view should receive those arguments:
<dl> <dl>
<dt class="inline">{{ 'Date of birth'|trans }}</dt> <dt class="inline">{{ 'Date of birth'|trans }}</dt>
<dd>{{ person.dateOfBirth.format(date_format) <dd>
|default( 'Unknown date of birth'|trans ) }}</dd> {%- if person.dateOfBirth is not null -%}
{{ person.dateOfBirth|localizeddate('long', 'none') }}
{%- else -%}
{{ 'Unknown date of birth'|trans }}
{%- endif -%}
</dd>
<dt class="inline">{{ 'Place of birth'|trans }}</dt> <dt class="inline">{{ 'Place of birth'|trans }}</dt>

View File

@ -42,7 +42,7 @@
person.genre)|trans }} person.genre)|trans }}
{% else %} {% else %}
{% transchoice person.genreNumeric {% 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% {0} Born the %date% | {1} Born the %date%
{% endtranschoice %} {% endtranschoice %}
{% endif %} {% endif %}