Skip to content

RaphaelCorrotte/Gooday

Repository files navigation

Gooday

Gooday is a date manager written in ruby. It is a simple date manager that allows you to stringify dates in many languages.

Installation

Install the gem and add to the application's Gemfile by executing:

$ bundle add gooday

If bundler is not being used to manage dependencies, install the gem by executing:

$ gem install gooday

Usage

To use Gooday. You have to initialize it. The default language is English (en). The module includes French (fr) and English (en)

require "gooday"

gooday = Gooday.new(Time.now)

Locale

You can change the language by passing the language as an argument:

gooday.locale("fr")

You can also set a locale directory, which will be used to load the language files. (This loads a YAML file)

gooday.locale("fr", path: "PATH/TO/LOCALE", target: "yml")

Add & Set

You can add days, months, seconds with Gooday. You can also set the date with Gooday.

gooday = Gooday.new(Time.now)
gooday.set(:month => "April", :day => 2, :year => 2020)
gooday.add(:days => 28)

This code sets the date to April, 2 2020 and adds 28 days to it.

Date parser

With the regexes specified in locales file you can parse the dates. The parsed dates are returned as an array.

gooday = Gooday.new(Time.now)
gooday.locale("fr")
parsed = date.parse_string("Nous sommes le 17/02/2021. Demain nous serons le 18 Février 2021")
puts parsed[0]

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/Senchuu/Gooday. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Gooday project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.