Fix 3710 correct show date with letter english (#3936)

Les dates sont maintenant affichées au format "12 juillet 2019"
This commit is contained in:
Pierre de La Morinerie 2019-06-12 18:57:34 +02:00 committed by GitHub
commit 77e6296842
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 80 additions and 23 deletions

View file

@ -112,4 +112,12 @@ module ApplicationHelper
root_path
end
end
def try_format_date(date)
date.present? ? I18n.l(date) : ''
end
def try_format_datetime(datetime)
datetime.present? ? I18n.l(datetime) : ''
end
end

View file

@ -6,7 +6,7 @@ class Champs::DateChamp < Champ
end
def to_s
value.present? ? Date.parse(value).strftime('%d/%m/%Y') : ""
value.present? ? I18n.l(Date.parse(value)) : ""
end
private

View file

@ -5,6 +5,10 @@ class Champs::DatetimeChamp < Champ
# Text search is pretty useless for datetimes so were not including these champs
end
def to_s
value.present? ? I18n.l(Time.zone.parse(value)) : ""
end
private
def format_before_save

View file

@ -20,9 +20,9 @@
- if procedure.publiee?
%td.procedure-lien= link_to(procedure_lien(procedure), procedure_lien(procedure))
- if procedure.publiee_ou_archivee?
%td= link_to(procedure.published_at.present? ? procedure.published_at.strftime('%d/%m/%Y %H:%M') : "", admin_procedure_href)
%td= link_to(procedure.published_at.present? ? try_format_datetime(procedure.published_at) : "", admin_procedure_href)
- else
%td= link_to(procedure.created_at.strftime('%d/%m/%Y %H:%M'), admin_procedure_href)
%td= link_to(try_format_datetime(procedure.created_at), admin_procedure_href)
%td
= link_to('Cloner', admin_procedure_clone_path(procedure.id), data: { method: :put }, class: 'btn-sm btn-primary clone-btn')
- if !procedure.publiee_ou_archivee?

View file

@ -5,7 +5,7 @@
%p
Vous avez fait la demande dun compte administrateur sur demarches-simplifiees.fr.
Votre compte a été créé mais reste inactif, il arrivera à expiration le #{@expiration_date.strftime("%d/%m/%Y")}
Votre compte a été créé mais reste inactif, il arrivera à expiration le #{try_format_date(@expiration_date)}
%p
Afin dactiver votre compte, veuillez cliquer sur le lien ci-dessous :

View file

@ -1,6 +1,6 @@
%tr{ id: "procedure-#{@procedure.id}-administrateur-#{administrateur.id}" }
%td= administrateur.email
%td= administrateur.created_at.strftime('%d/%m/%Y %H:%M')
%td= try_format_datetime(administrateur.created_at)
%td= administrateur.registration_state
%td
- if administrateur == current_administrateur

View file

@ -30,6 +30,10 @@
= render partial: "shared/champs/siret/show", locals: { champ: c, profile: profile }
- when TypeDeChamp.type_champs.fetch(:textarea)
= render partial: "shared/champs/textarea/show", locals: { champ: c }
- when TypeDeChamp.type_champs.fetch(:date)
= c.to_s
- when TypeDeChamp.type_champs.fetch(:datetime)
= c.to_s
- else
= sanitize(c.to_s)
@ -37,4 +41,4 @@
%td.updated-at
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }
modifié le
= c.updated_at.strftime("%d/%m/%Y à %H:%M")
= try_format_datetime(c.updated_at)

View file

@ -22,7 +22,7 @@
%td= etablissement.naf
%tr
%th.libelle Date de création :
%td= etablissement.entreprise.date_creation&.strftime("%d/%m/%Y")
%td= try_format_date(etablissement.entreprise.date_creation)
%tr
%th.libelle Effectif de l'organisation :
%td= effectif(etablissement)
@ -64,10 +64,10 @@
%td= etablissement.association_objet
%tr
%th.libelle Date de création :
%td= etablissement.association_date_creation&.strftime("%d/%m/%Y")
%td= try_format_date(etablissement.association_date_creation)
%tr
%th.libelle Date de publication :
%td= etablissement.association_date_publication&.strftime("%d/%m/%Y")
%td= try_format_date(etablissement.association_date_publication)
%tr
%th.libelle Date de déclaration :
%td= etablissement.association_date_declaration&.strftime("%d/%m/%Y")
%td= try_format_date(etablissement.association_date_declaration)

View file

@ -12,4 +12,4 @@
- if individual.birthdate.present?
%tr
%th.libelle Date de naissance :
%td= individual.birthdate&.strftime("%d/%m/%Y")
%td= try_format_date(individual.birthdate)

View file

@ -23,11 +23,11 @@
= link_to pj.content_url, { target: :blank, rel: :noopener } do
%span.filename= display_pj_filename(pj)
%span
ajoutée le #{pj.created_at.strftime('%d/%m/%Y à %H:%M')}
ajoutée le #{try_format_datetime(pj.created_at)}
- else
%td Pièce non fournie
%td.updated-at
- if pj
%span{ class: highlight_if_unseen_class(demande_seen_at, pj.updated_at) }
modifié le
= pj.updated_at.strftime("%d/%m/%Y à %H:%M")
= try_format_datetime(pj.updated_at)

View file

@ -3,6 +3,6 @@
.card-title
Le dépôt de dossier est fermé
- if dossier.procedure.archived_at.present?
Il n'est plus possible de déposer de dossier pour cette démarche en ligne depuis le #{dossier.procedure.archived_at.strftime("%d/%m/%Y")}.
Il n'est plus possible de déposer de dossier pour cette démarche en ligne depuis le #{try_format_date(dossier.procedure.archived_at)}.
- else
Il n'est plus possible de déposer de dossier pour cette démarche en ligne.

View file

@ -5,7 +5,7 @@
- if champ.updated_at.present? && seen_at.present?
%span.updated-at{ class: highlight_if_unseen_class(seen_at, champ.updated_at) }
= "modifié le #{champ.updated_at.strftime('%d/%m/%Y à %H:%M')}"
= "modifié le #{try_format_datetime(champ.updated_at)}"
- if champ.description.present?
%span.notice= string_to_html(champ.description)

View file

@ -13,12 +13,12 @@
%li
Date de création :
= etablissement.association_date_creation&.strftime('%d/%m/%Y')
= try_format_date(etablissement.association_date_creation)
%li
Date de déclaration :
= etablissement.association_date_declaration&.strftime('%d/%m/%Y')
= try_format_date(etablissement.association_date_declaration)
%li
Date de publication :
= etablissement.association_date_publication&.strftime('%d/%m/%Y')
= try_format_date(etablissement.association_date_publication)

View file

@ -22,7 +22,7 @@
%li
Date de création :
= etablissement.entreprise.date_creation&.strftime('%d/%m/%Y')
= try_format_date(etablissement.entreprise.date_creation)
%li
Effectif organisation :

View file

@ -47,7 +47,7 @@
= render partial: 'shared/dossiers/status_badge', locals: { dossier: dossier }
%td.updated-at-col
= link_to(url_for_dossier(dossier), class: 'cell-link') do
= dossier.updated_at.strftime("%d/%m/%Y")
= try_format_date(dossier.updated_at)
%td.action-col.action-col
= render partial: 'dossier_actions', locals: { dossier: dossier }
= paginate(@dossiers)

View file

@ -249,7 +249,7 @@ fr:
- vendredi
- samedi
formats:
default: "%d/%m/%Y"
default: "%d %B %Y"
short: "%e %b"
long: "%e %B %Y"
datetime:
@ -290,6 +290,9 @@ fr:
x_seconds:
one: 1 seconde
other: "%{count} secondes"
time:
formats:
default: "%d %B %Y %R"
pluralize:
case:
zero: dossier

View file

@ -17,4 +17,42 @@ describe ApplicationHelper do
it { is_expected.to be_nil }
end
end
describe "#try_format_date" do
subject { try_format_date(date) }
describe 'try formatting a date' do
let(:date) { Date.new(2019, 01, 24) }
it { is_expected.to eq("24 janvier 2019") }
end
describe 'try formatting a blank string' do
let(:date) { "" }
it { is_expected.to eq("") }
end
describe 'try formatting a nil string' do
let(:date) { nil }
it { is_expected.to eq("") }
end
end
describe "#try_format_datetime" do
subject { try_format_datetime(datetime) }
describe 'try formatting 31/01/2019 11:25' do
let(:datetime) { Time.zone.local(2019, 01, 31, 11, 25, 00) }
it { is_expected.to eq("31 janvier 2019 11:25") }
end
describe 'try formatting a blank string' do
let(:datetime) { "" }
it { is_expected.to eq("") }
end
describe 'try formatting a nil string' do
let(:datetime) { nil }
it { is_expected.to eq("") }
end
end
end

View file

@ -238,7 +238,7 @@ describe TagsSubstitutionConcern, type: :model do
.update(value: '2017-09-13 09:00')
end
it { is_expected.to eq('15/04/2017 2017-09-13 09:00') }
it { is_expected.to eq('15 avril 2017 13 septembre 2017 09:00') }
end
end
end

View file

@ -38,7 +38,7 @@ describe 'shared/dossiers/demande.html.haml', type: :view do
expect(rendered).to include(individual.gender)
expect(rendered).to include(individual.nom)
expect(rendered).to include(individual.prenom)
expect(rendered).to include(individual.birthdate.strftime("%d/%m/%Y"))
expect(rendered).to include(I18n.l(individual.birthdate))
end
end