From b1b2cfa8b157601ca2f773ada45d6147a6288805 Mon Sep 17 00:00:00 2001 From: taitus Date: Wed, 2 Jun 2021 11:19:04 +0200 Subject: [PATCH] Add new time format :short_datetime Improve DurationComponent for render time without seconds. I believe that adding the seconds in this component is not necessary. --- .../admin/budgets/duration_component.rb | 2 +- config/locales/en/rails.yml | 1 + config/locales/es/rails.yml | 5 +++-- .../admin/budgets/duration_component_spec.rb | 6 +++--- spec/system/admin/budgets_spec.rb | 16 ++++++++-------- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/app/components/admin/budgets/duration_component.rb b/app/components/admin/budgets/duration_component.rb index 3e7a80207..177845928 100644 --- a/app/components/admin/budgets/duration_component.rb +++ b/app/components/admin/budgets/duration_component.rb @@ -24,6 +24,6 @@ class Admin::Budgets::DurationComponent < ApplicationComponent end def formatted_date(time) - time_tag(time, format: :datetime) + time_tag(time, format: :short_datetime) end end diff --git a/config/locales/en/rails.yml b/config/locales/en/rails.yml index 460857624..1c653dbde 100644 --- a/config/locales/en/rails.yml +++ b/config/locales/en/rails.yml @@ -199,5 +199,6 @@ en: default: "%a, %d %b %Y %H:%M:%S %z" long: "%B %d, %Y %H:%M" short: "%d %b %H:%M" + short_datetime: "%Y-%m-%d %H:%M" api: "%Y-%m-%d %H" pm: pm diff --git a/config/locales/es/rails.yml b/config/locales/es/rails.yml index eaff6932d..eade2c082 100644 --- a/config/locales/es/rails.yml +++ b/config/locales/es/rails.yml @@ -9,7 +9,7 @@ es: - vie - sáb abbr_month_names: - - + - - ene - feb - mar @@ -35,7 +35,7 @@ es: long: "%d de %B de %Y" short: "%d de %b" month_names: - - + - - enero - febrero - marzo @@ -193,5 +193,6 @@ es: default: "%A, %d de %B de %Y %H:%M:%S %z" long: "%d de %B de %Y %H:%M" short: "%d de %b %H:%M" + short_datetime: "%d/%m/%Y %H:%M" api: "%d/%m/%Y %H" pm: pm diff --git a/spec/components/admin/budgets/duration_component_spec.rb b/spec/components/admin/budgets/duration_component_spec.rb index fbbd51b73..5e6c78e24 100644 --- a/spec/components/admin/budgets/duration_component_spec.rb +++ b/spec/components/admin/budgets/duration_component_spec.rb @@ -12,7 +12,7 @@ describe Admin::Budgets::DurationComponent, type: :component do render dates - expect(page.text).to eq "2015-08-01 12:00:00 - 2016-09-30 16:29:59" + expect(page.text).to eq "2015-08-01 12:00 - 2016-09-30 16:29" expect(dates).to be_html_safe end @@ -20,7 +20,7 @@ describe Admin::Budgets::DurationComponent, type: :component do durable = double(starts_at: Time.zone.local(2015, 8, 1, 12, 0, 0), ends_at: nil) render Admin::Budgets::DurationComponent.new(durable).dates - expect(page.text).to eq "2015-08-01 12:00:00 - " + expect(page.text).to eq "2015-08-01 12:00 - " end it "shows the end date when no start date is defined" do @@ -28,7 +28,7 @@ describe Admin::Budgets::DurationComponent, type: :component do render Admin::Budgets::DurationComponent.new(durable).dates - expect(page.text).to eq "- 2016-09-30 16:29:59" + expect(page.text).to eq "- 2016-09-30 16:29" end end diff --git a/spec/system/admin/budgets_spec.rb b/spec/system/admin/budgets_spec.rb index bab9408fe..bb41724dc 100644 --- a/spec/system/admin/budgets_spec.rb +++ b/spec/system/admin/budgets_spec.rb @@ -202,14 +202,14 @@ describe "Admin budgets", :admin do "Reviewing voting" ], [ - "2015-07-15 00:00:00 - 2015-08-14 23:59:59", - "2015-08-15 00:00:00 - 2015-09-14 23:59:59", - "2015-09-15 00:00:00 - 2015-10-14 23:59:59", - "2015-10-15 00:00:00 - 2015-11-14 23:59:59", - "2015-11-15 00:00:00 - 2015-12-14 23:59:59", - "2015-11-15 00:00:00 - 2016-01-14 23:59:59", - "2016-01-15 00:00:00 - 2016-02-14 23:59:59", - "2016-02-15 00:00:00 - 2016-03-14 23:59:59" + "2015-07-15 00:00 - 2015-08-14 23:59", + "2015-08-15 00:00 - 2015-09-14 23:59", + "2015-09-15 00:00 - 2015-10-14 23:59", + "2015-10-15 00:00 - 2015-11-14 23:59", + "2015-11-15 00:00 - 2015-12-14 23:59", + "2015-11-15 00:00 - 2016-01-14 23:59", + "2016-01-15 00:00 - 2016-02-14 23:59", + "2016-02-15 00:00 - 2016-03-14 23:59" ], [ "Yes",