[fix #3710] date with letter
Co-Authored-By: simon lehericey <mail@simon.lehericey.net>
This commit is contained in:
parent
d11e246112
commit
abcd58c35d
7 changed files with 62 additions and 9 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
= try_format_date(c.to_s)
|
||||
- when TypeDeChamp.type_champs.fetch(:datetime)
|
||||
= try_format_datetime(c.to_s)
|
||||
- else
|
||||
= sanitize(c.to_s)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 :
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue