The purpose of this gem is to add a helper needed to display proper Date range informations.
For example: "Du 3 au 5 octobre 2024" or "Du 3 octobre 2023 au 12 janvier 2024"
Add this line to your application's Gemfile:
gem 'i18n_date_range'
And then execute:
$ bundle install
This gem comes with an integrated view helper: date_range_i18n
which takes 3 parameters:
- date_from
- date_to (optional)
- a hash of additional formatting options(optional)
The options hash currently support 2 arguments:
- format: can be
:short
or:long
(default is :short) - layout: can be
:one_line
or:two_lines
(default is :one_line)
"Short" format means without the explicit day name (September 8, 2024).
"Long" format means with it (Friday, September 8, 2024).
"One line" layout means the string will be displayed on one line only (From September 8, 2024 to September 8, 2025)
"Two lines" layout means the result will be displayed on 2 lines,separated with <br>
(September 8, 2024
September 8, 2025)
This gem is based on I18n. Feel free to overwrite any key you want.
Refer to config/locales/fr.yml to see what can be edited.
Tests are done with RSpec, and Combustion is used to simulate the Rails app. Rubocop is used to check the syntax.
bundle exec rspec
to launch the testsrake rubocop
to launch Rubocoprake
to launch both (default)
Bug reports and pull requests are welcome on GitHub at https://github.com/noesya/i18n_date_range.
The gem is available as open source under the terms of the MIT License.
https://coderwall.com/p/fkg-ng/display-date-ranges-in-text-in-rails