Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/presenters/idv/in_person/ready_to_verify_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ def days_remaining
end

def formatted_due_date
enrollment.due_date.in_time_zone(USPS_SERVER_TIMEZONE).
strftime(I18n.t('time.formats.event_date'))
I18n.l(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorta curious why this had to change from strftime to I18n.l, or was that more of a readability improvement / consistent change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That previous version wasn't displaying the months with the correct translated month name. The I18n.l or localize method will correctly translate the month names when formatting the date.

enrollment.due_date.in_time_zone(USPS_SERVER_TIMEZONE),
format: :event_date,
)
end

def selected_location_hours(prefix)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ def initialize(enrollment:, url_options:, visited_location_name:)
end

def formatted_verified_date
enrollment.status_updated_at.in_time_zone(USPS_SERVER_TIMEZONE).strftime(
I18n.t('time.formats.event_date'),
I18n.l(
enrollment.status_updated_at.in_time_zone(USPS_SERVER_TIMEZONE),
format: :event_date,
)
end

Expand Down
4 changes: 2 additions & 2 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,7 @@ image_description.warning: Señal amarilla de precaución
in_person_proofing.body.barcode.cancel_link_text: Cancele su código de barras
in_person_proofing.body.barcode.close_window: Ya puede cerrar esta ventana.
in_person_proofing.body.barcode.deadline: Debe acudir a cualquier oficina de correos participante antes del %{deadline}
in_person_proofing.body.barcode.deadline_restart: Si vence el plazo, su información no se guardará y tendrá que reiniciar el proceso.
in_person_proofing.body.barcode.deadline_restart: Si acude después del plazo, su información no se guardará y tendrá que reiniciar el proceso.
in_person_proofing.body.barcode.eipp_tag: Código de barras piloto mejorado GSA
in_person_proofing.body.barcode.eipp_what_to_bring: 'Según el tipo de identificación que tenga, es posible que deba presentar documentos comprobatorios. Lea con atención las opciones siguientes:'
in_person_proofing.body.barcode.email_sent: Enviamos el código de barras y la información más abajo al correo electrónico que usó para iniciar sesión
Expand Down Expand Up @@ -1570,7 +1570,7 @@ step_indicator.status.complete: Completado
step_indicator.status.current: Este paso
step_indicator.status.not_complete: No completado
time.am: a. m.
time.formats.event_date: '%B %-d, %Y'
time.formats.event_date: '%-d de %B de %Y'
time.formats.event_time: '%-l:%M %p'
time.formats.event_timestamp: '%B %-d, %Y a las %-l:%M %p'
time.formats.event_timestamp_js: '%{month} %{day}, %{year} a las %{hour}:%{minute} %{day_period}'
Expand Down
2 changes: 1 addition & 1 deletion config/locales/zh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1571,7 +1571,7 @@ step_indicator.status.complete: 完成了
step_indicator.status.current: 目前步骤
step_indicator.status.not_complete: 未完成
time.am: 上午
time.formats.event_date: '%B %-d, %Y'
time.formats.event_date: '%Y年%B%-d日'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏🏻

time.formats.event_time: '%-l:%M %p'
time.formats.event_timestamp: '%B %-d, %Y at %-l:%M %p'
time.formats.event_timestamp_js: '%{year}年%{month}月%{day}日, %{hour}:%{minute} %{day_period}'
Expand Down
1 change: 0 additions & 1 deletion spec/i18n_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ class BaseTask
{ key: 'simple_form.no', locales: %i[es] }, # "No" is "No" in Spanish
{ key: 'telephony.format_length.six', locales: %i[zh] }, # numeral is not translated
{ key: 'telephony.format_length.ten', locales: %i[zh] }, # numeral is not translated
{ key: 'time.formats.event_date', locales: %i[es zh] },
{ key: 'time.formats.event_time', locales: %i[es zh] },
{ key: 'time.formats.event_timestamp', locales: %i[zh] },
{ key: 'time.formats.full_date', locales: %i[es] }, # format is the same in Spanish and English
Expand Down
32 changes: 22 additions & 10 deletions spec/presenters/idv/in_person/ready_to_verify_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,33 @@
)
end
subject(:presenter) { described_class.new(enrollment: enrollment) }
describe '#formatted_due_date' do
subject(:formatted_due_date) { presenter.formatted_due_date }

around do |example|
Time.use_zone('UTC') { example.run }
end

it 'returns a formatted due date' do
expect(formatted_due_date).to eq 'August 12, 2023'
describe '#formatted_due_date' do
let(:enrollment_established_at) { DateTime.new(2024, 7, 5) }

context 'when the enrollment has an enrollment_established_at time' do
[
['English', :en, 'August 3, 2024'],
['Spanish', :es, '3 de agosto de 2024'],
['French', :fr, '3 août 2024'],
['Chinese', :zh, '2024年8月3日'],
].each do |language, locale, expected|
context "when locale is #{language}" do
before do
I18n.locale = locale
end

it "returns the formatted due date in #{language}" do
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good test coverage. 👍🏻

expect(presenter.formatted_due_date).to eq(expected)
end
end
end
end

context 'there is no enrollment_established_at' do
context 'when the enrollment does not have an enrollment_established_at time' do
let(:enrollment_established_at) { nil }
it 'returns formatted due date when no enrollment_established_at' do
expect(formatted_due_date).to eq 'July 13, 2023'
expect(presenter.formatted_due_date).to eq 'July 13, 2023'
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,25 @@
end

describe '#formatted_verified_date' do
around do |example|
Time.use_zone('UTC') { example.run }
before do
enrollment.update(status_updated_at: DateTime.new(2024, 7, 5))
end

it 'returns a formatted verified date' do
enrollment.update(status_updated_at: status_updated_at)
expect(presenter.formatted_verified_date).to eq 'July 13, 2022'
[
['English', :en, 'July 4, 2024'],
['Spanish', :es, '4 de julio de 2024'],
['French', :fr, '4 juillet 2024'],
['Chinese', :zh, '2024年7月4日'],
].each do |language, locale, expected|
context "when locale is #{language}" do
before do
I18n.locale = locale
end

it "returns the formatted due date in #{language}" do
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

expect(presenter.formatted_verified_date).to eq(expected)
end
end
end
end

Expand Down