0.0
No commit activity in last 3 years
No release in over 3 years
Returns a date when given a week number and a day of the week.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.14
~> 10.0
~> 3.0
 Project Readme

WeekToDate

This gem is for apps that use calendars or dates in both monthly and weekly formats. If you are tracking events using the week number (i.e. out of the 52 weeks in a year) and days of the week but you need to convert those days to a traditional date format, use this gem.

Installation

Add this line to your application's Gemfile:

gem 'week_to_date'

And then execute:

$ bundle

Or install it yourself as:

$ gem install week_to_date

Usage

  1. To get the day, run this command:

WeekToDate::GetDate.date_from_num(year, week_number, day_number)

  • For the week_number, enter the week in the year.
  • For day_number enter the position the day holds in the following array [monday, tuesday, wednesday, thursday, friday, saturday, sunday]

You can enter the day as a string with the following command:

WeekToDate::GetDate.get_date(year, week_number, day_as_string)

  1. To get the week and day number within the week (according to the array above), run this command:

WeekToDate::GetWeek.week(date)

  • Enter the date in the format "year-month-day"
  • Make sure date is formated as a string

Note: This gem uses the Striftime concept of a week that starts on Sunday for outputs (though not for inputs at this time).

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 tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/week_to_date.

License

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