From 8525761332018fcd6a6b9050f7bd68b33514888c Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 2 Apr 2019 14:38:47 +0200 Subject: [PATCH] Revert english dates --- app/helpers/application_helper.rb | 16 ----- .../shared/dossiers/_champ_row.html.haml | 4 -- .../dossiers/_identite_entreprise.html.haml | 8 +-- .../_infos_association.html.haml | 6 +- .../etablissement/_infos_entreprise.html.haml | 2 +- spec/helpers/application_helper_spec.rb | 58 ------------------- 6 files changed, 8 insertions(+), 86 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index efadf5712..28dc0af2a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -119,20 +119,4 @@ module ApplicationHelper {} end end - - def try_format_date(date) - begin - date.is_a?(String) ? Date.parse(date).strftime("%d %B %Y") : date.strftime("%d %B %Y") - rescue - date - end - end - - def try_format_datetime(datetime) - begin - datetime.is_a?(String) ? Time.zone.parse(datetime).strftime("%d %B %Y %R") : datetime.strftime("%d %B %Y %R") - rescue - datetime - end - end end diff --git a/app/views/shared/dossiers/_champ_row.html.haml b/app/views/shared/dossiers/_champ_row.html.haml index 62f6feb87..361c6e786 100644 --- a/app/views/shared/dossiers/_champ_row.html.haml +++ b/app/views/shared/dossiers/_champ_row.html.haml @@ -30,10 +30,6 @@ = 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) - = try_format_date(c.to_s) - - when TypeDeChamp.type_champs.fetch(:datetime) - = try_format_datetime(c.to_s) - else = sanitize(c.to_s) diff --git a/app/views/shared/dossiers/_identite_entreprise.html.haml b/app/views/shared/dossiers/_identite_entreprise.html.haml index 33f0ce548..87be8390f 100644 --- a/app/views/shared/dossiers/_identite_entreprise.html.haml +++ b/app/views/shared/dossiers/_identite_entreprise.html.haml @@ -22,7 +22,7 @@ %td= etablissement.naf %tr %th.libelle Date de création : - %td= try_format_date(etablissement.entreprise.date_creation) + %td= etablissement.entreprise.date_creation&.strftime("%d/%m/%Y") %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= try_format_date(etablissement.association_date_creation) + %td= etablissement.association_date_creation&.strftime("%d/%m/%Y") %tr %th.libelle Date de publication : - %td= try_format_date(etablissement.association_date_publication) + %td= etablissement.association_date_publication&.strftime("%d/%m/%Y") %tr %th.libelle Date de déclaration : - %td= try_format_date(etablissement.association_date_declaration) + %td= etablissement.association_date_declaration&.strftime("%d/%m/%Y") diff --git a/app/views/users/dossiers/etablissement/_infos_association.html.haml b/app/views/users/dossiers/etablissement/_infos_association.html.haml index d8afcbdb6..4fe9b8f91 100644 --- a/app/views/users/dossiers/etablissement/_infos_association.html.haml +++ b/app/views/users/dossiers/etablissement/_infos_association.html.haml @@ -13,12 +13,12 @@ %li Date de création : - = try_format_date(etablissement.association_date_creation) + = etablissement.association_date_creation&.strftime('%d/%m/%Y') %li Date de déclaration : - = try_format_date(etablissement.association_date_declaration) + = etablissement.association_date_declaration&.strftime('%d/%m/%Y') %li Date de publication : - = try_format_date(etablissement.association_date_publication) + = etablissement.association_date_publication&.strftime('%d/%m/%Y') diff --git a/app/views/users/dossiers/etablissement/_infos_entreprise.html.haml b/app/views/users/dossiers/etablissement/_infos_entreprise.html.haml index 9667a54bd..54f03b486 100644 --- a/app/views/users/dossiers/etablissement/_infos_entreprise.html.haml +++ b/app/views/users/dossiers/etablissement/_infos_entreprise.html.haml @@ -22,7 +22,7 @@ %li Date de création : - = try_format_date(etablissement.entreprise.date_creation) + = etablissement.entreprise.date_creation&.strftime('%d/%m/%Y') %li Effectif organisation : diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 6998f17d2..30a7becef 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -17,62 +17,4 @@ describe ApplicationHelper do it { is_expected.to be_nil } end end - - describe "#try_format_date" do - subject { try_format_date(date) } - - describe 'try formatting 2019-01-24' do - let(:date) { "2019-01-24" } - it { is_expected.to eq("24 January 2019") } - end - - describe 'try formatting 24/01/2019' do - let(:date) { "24/01/2019" } - it { is_expected.to eq("24 January 2019") } - end - - describe 'try formatting 2019-01-32' do - let(:date) { "2019-01-32" } - it { is_expected.to eq("2019-01-32") } - 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 be_nil } - end - end - - describe "#try_format_datetime" do - subject { try_format_datetime(datetime) } - - describe 'try formatting 31/01/2019 11:25' do - let(:datetime) { "31/01/2019 11:25" } - it { is_expected.to eq("31 January 2019 11:25") } - end - - describe 'try formatting 2019-01-31 11:25' do - let(:datetime) { "2019-01-31 11:25" } - it { is_expected.to eq("31 January 2019 11:25") } - end - - describe 'try formatting 2019-01-32 11:25' do - let(:datetime) { "2019-01-32 11:25" } - it { is_expected.to eq("2019-01-32 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 be_nil } - end - end end