Skip to content

Commit

Permalink
Fix one application_helper fuzzy date error
Browse files Browse the repository at this point in the history
  • Loading branch information
ut committed Jan 9, 2025
1 parent c04081c commit 518ce9b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def smart_date_display_with_qualifier(startdate, enddate, startdate_qualifier =
# ca. 1980s
"ca. #{startdate.strftime('%Y')}s ‒ #{enddate.strftime('%Y')}s"
end
elsif startdate.strftime('%Y').to_i == enddate.strftime('%Y')
elsif startdate.strftime('%Y').to_i == enddate.strftime('%Y').to_i
if startdate.strftime('%d.%m') == '01.01' && enddate.strftime('%d.%m') == '31.12'
# ca. 1981
"ca. #{startdate.strftime('%Y')}"
Expand Down
10 changes: 10 additions & 0 deletions spec/helpers/application_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@
enddate = '2017-01-01 00:00:00'.to_time
expect(helper.smart_date_display_with_qualifier(startdate, enddate, 'circa', 'circa')).to eq('ca. 2015 ‒ 2017')
end
it 'returns ca. %Y ‒ %Y with qualifier/2' do
startdate = '2015-01-01 00:00:00'.to_time
enddate = '2016-01-01 00:00:00'.to_time
expect(helper.smart_date_display_with_qualifier(startdate, enddate, 'circa', 'circa')).to eq('ca. 2015 ‒ 2016')
end
it 'returns ca. %Y with qualifier' do
startdate = '2015-01-01 00:00:00'.to_time
enddate = '2015-12-31 00:00:00'.to_time
expect(helper.smart_date_display_with_qualifier(startdate, enddate, 'circa', 'circa')).to eq('ca. 2015')
end
it 'returns ca. %Ys with qualifier' do
startdate = '2010-01-01 00:00:00'.to_time
enddate = '2020-01-01 00:00:00'.to_time
Expand Down

0 comments on commit 518ce9b

Please sign in to comment.