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.
This commit is contained in:
taitus
2021-06-02 11:19:04 +02:00
parent 29ff9d4296
commit b1b2cfa8b1
5 changed files with 16 additions and 14 deletions

View File

@@ -24,6 +24,6 @@ class Admin::Budgets::DurationComponent < ApplicationComponent
end end
def formatted_date(time) def formatted_date(time)
time_tag(time, format: :datetime) time_tag(time, format: :short_datetime)
end end
end end

View File

@@ -199,5 +199,6 @@ en:
default: "%a, %d %b %Y %H:%M:%S %z" default: "%a, %d %b %Y %H:%M:%S %z"
long: "%B %d, %Y %H:%M" long: "%B %d, %Y %H:%M"
short: "%d %b %H:%M" short: "%d %b %H:%M"
short_datetime: "%Y-%m-%d %H:%M"
api: "%Y-%m-%d %H" api: "%Y-%m-%d %H"
pm: pm pm: pm

View File

@@ -9,7 +9,7 @@ es:
- vie - vie
- sáb - sáb
abbr_month_names: abbr_month_names:
- -
- ene - ene
- feb - feb
- mar - mar
@@ -35,7 +35,7 @@ es:
long: "%d de %B de %Y" long: "%d de %B de %Y"
short: "%d de %b" short: "%d de %b"
month_names: month_names:
- -
- enero - enero
- febrero - febrero
- marzo - marzo
@@ -193,5 +193,6 @@ es:
default: "%A, %d de %B de %Y %H:%M:%S %z" default: "%A, %d de %B de %Y %H:%M:%S %z"
long: "%d de %B de %Y %H:%M" long: "%d de %B de %Y %H:%M"
short: "%d de %b %H:%M" short: "%d de %b %H:%M"
short_datetime: "%d/%m/%Y %H:%M"
api: "%d/%m/%Y %H" api: "%d/%m/%Y %H"
pm: pm pm: pm

View File

@@ -12,7 +12,7 @@ describe Admin::Budgets::DurationComponent, type: :component do
render dates 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 expect(dates).to be_html_safe
end 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) durable = double(starts_at: Time.zone.local(2015, 8, 1, 12, 0, 0), ends_at: nil)
render Admin::Budgets::DurationComponent.new(durable).dates 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 end
it "shows the end date when no start date is defined" do 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 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
end end

View File

@@ -202,14 +202,14 @@ describe "Admin budgets", :admin do
"Reviewing voting" "Reviewing voting"
], ],
[ [
"2015-07-15 00:00:00 - 2015-08-14 23:59:59", "2015-07-15 00:00 - 2015-08-14 23:59",
"2015-08-15 00:00:00 - 2015-09-14 23:59:59", "2015-08-15 00:00 - 2015-09-14 23:59",
"2015-09-15 00:00:00 - 2015-10-14 23:59:59", "2015-09-15 00:00 - 2015-10-14 23:59",
"2015-10-15 00:00:00 - 2015-11-14 23:59:59", "2015-10-15 00:00 - 2015-11-14 23:59",
"2015-11-15 00:00:00 - 2015-12-14 23:59:59", "2015-11-15 00:00 - 2015-12-14 23:59",
"2015-11-15 00:00:00 - 2016-01-14 23:59:59", "2015-11-15 00:00 - 2016-01-14 23:59",
"2016-01-15 00:00:00 - 2016-02-14 23:59:59", "2016-01-15 00:00 - 2016-02-14 23:59",
"2016-02-15 00:00:00 - 2016-03-14 23:59:59" "2016-02-15 00:00 - 2016-03-14 23:59"
], ],
[ [
"Yes", "Yes",