Project

datesplit

0.0
No commit activity in last 3 years
No release in over 3 years
Generate date objects from a date duration string (eg. 'September 9th-12th, 2012')
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

Datesplit

Datesplit is a gem for converting date duration strings such as "August 14th to September 21st, 2012" into date objects. It piggybacks heavily off of Date#parse.

Usage

Datesplit has only 3 public methods: start_date, end_date, and duration. Each does pretty much what you would expect.

dates = Datesplit.new('April 9th to April 20th, 2012')
dates.range                    # Returns a range of Date objects from April 9th..April 20th
dates.start_date               # Returns #<Date: 4912053/2,0,2299161>
dates.end_date                 # Returns #<Date: 4912075/2,0,2299161>
dates.number_of_days           # Returns 11

dates.each { |d| puts d }      # Steps through each date in the range between April 9th and 20th (inclusive)

Formats

A list of formats that Datesplit undestands can be found in the spec/datesplit_spec.rb. This list is small but growing.