Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/noesya/i18n_date_range
https://github.com/noesya/i18n_date_range
Last synced: 8 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/noesya/i18n_date_range
- Owner: noesya
- License: mit
- Created: 2023-09-08T10:51:35.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-02T02:13:09.000Z (6 months ago)
- Last Synced: 2025-01-23T03:46:12.964Z (9 days ago)
- Language: Ruby
- Size: 64.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# I18nDateRange
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"## Installation
Add this line to your application's Gemfile:
```ruby
gem 'i18n_date_range'
```And then execute:
$ bundle install
## Usage
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 `
` (September 8, 2024
September 8, 2025)## Change texts or formats
This gem is based on I18n. Feel free to overwrite any key you want.
Refer to [config/locales/fr.yml](config/locales/fr.yml) to see what can be edited.## Tests
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 tests
- `rake rubocop` to launch Rubocop
- `rake` to launch both (default)## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/noesya/i18n_date_range.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
## Bibliography
https://coderwall.com/p/fkg-ng/display-date-ranges-in-text-in-rails