Skip to content

Ruby gem for generating date objects from a date duration string (eg. 'September 9th-12th, 2012')

Notifications You must be signed in to change notification settings

SeanRoberts/datesplit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Ruby gem for generating date objects from a date duration string (eg. 'September 9th-12th, 2012')

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages