Merge pull request #3724 from betagouv/revert-english-dates

Revert english dates
This commit is contained in:
LeSim 2019-04-02 14:49:03 +02:00 committed by GitHub
commit 22e96c63c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 8 additions and 86 deletions

View file

@ -119,20 +119,4 @@ module ApplicationHelper
{} {}
end end
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 end

View file

@ -30,10 +30,6 @@
= render partial: "shared/champs/siret/show", locals: { champ: c, profile: profile } = render partial: "shared/champs/siret/show", locals: { champ: c, profile: profile }
- when TypeDeChamp.type_champs.fetch(:textarea) - when TypeDeChamp.type_champs.fetch(:textarea)
= render partial: "shared/champs/textarea/show", locals: { champ: c } = 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 - else
= sanitize(c.to_s) = sanitize(c.to_s)

View file

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

View file

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

View file

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

View file

@ -17,62 +17,4 @@ describe ApplicationHelper do
it { is_expected.to be_nil } it { is_expected.to be_nil }
end end
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 end