0.01
Low commit activity in last 3 years
There's a lot of open issues
No release in over a year
DateTime wrapper to handle common date formats
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 10.0
 Project Readme

Build Status Coverage Status

Timetwister

A DateTime wrapper with improved date format parsing and fewer surprises.

Developed by the New York Public Library to transform freetext date metadata into machine-readable data.

Installation

Add this line to your application's Gemfile:

gem 'timetwister'

And then execute:

$ bundle

Or install it yourself as:

$ gem install timetwister

Usage

Takes a date (or list of dates) as a string, and returns a list of hashes with parsed date data.

Ruby

Returns a list of hashes of parsed date data.

require 'timetwister'
Timetwister.parse("Jun 1898 - [July 4 1900]")
 => [{:original_string=>"Jun 1898 - July 4 1900", :index_dates=>[1898, 1899, 1900], :date_start=>"1898-06-01", :date_end=>"1900-07-04", :date_start_full=>"1898-06-01", :date_end_full=>"1900-07-04", :inclusive_range=>true, :certainty=>"inferred", :test_data=>"330"}]

Command Line

Returns a JSON object of parsed date data.

$ timetwister 'december 21 2015'
[{"original_string":"december 21 2015","index_dates":[2015],"date_start":"2015-12-21","date_end":"2015-12-21","date_start_full":"2015-12-21","date_end_full":"2015-12-21","inclusive_range":null,"certainty":null,"test_data":"200"}]

Output explanation:

  • :original_string is the original input
  • :index_dates is an Array of each year encompassed by the provided date range
  • :date_start and :date_end are ISO8601 representations of the input date, with no assumed values
  • :date_start_full and :date_end_full are ISO8601 representations of the input date in YYYY-MM-DD format (using assumed values when needed)
  • :inclusive_range is whether or not the input value is a range
  • :certainty is the certainty of the provided date, based on use of flags and punctuation

Contributing

  1. Fork it ( https://github.com/[my-github-username]/timetwister/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Update specs to test for new features (rspec)
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create a new Pull Request

Contributors