0.0
No release in over 3 years
Check discrete of months, days and hours
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

>= 1.5
>= 0
>= 0
>= 1.1.5
>= 0

Runtime

 Project Readme

DateDiscreter

Check discrete of months, days and hours

Gem Version test Code Climate Coverage Status

Requirements

  • ruby 2.0+

Installation

Add this line to your application's Gemfile:

gem 'date_discreter'

And then execute:

$ bundle

Or install it yourself as:

$ gem install date_discreter

Usage

>> require "date_discreter"

discrete_months / continuous_months?

>> continuous_months = [Date.parse("2014-10-01"), Date.parse("2014-11-01"), Date.parse("2014-12-01")]
>> DateDiscreter.discrete_months(continuous_months)
=> []
>> DateDiscreter.continuous_months?(continuous_months)
=> true

>> discrete_months = [Date.parse("2014-10-01"), Date.parse("2014-12-01")]
>> DateDiscreter.discrete_months(discrete_months)
=> [Date.parse("2014-11-01")]
>> DateDiscreter.continuous_months?(discrete_months)
=> false

discrete_days / continuous_days?

>> continuous_days = [Date.parse("2014-12-01"), Date.parse("2014-12-02"), Date.parse("2014-12-03")]
>> DateDiscreter.discrete_days(continuous_days)
=> []
>> DateDiscreter.continuous_days?(continuous_days)
=> true

>> discrete_days = [Date.parse("2014-12-01"), Date.parse("2014-12-03")]
>> DateDiscreter.discrete_days(discrete_days)
=> [Date.parse("2014-12-02")]
>> DateDiscreter.continuous_days?(discrete_days)
=> false

discrete_hours / continuous_hours?

>> continuous_hours = [Time.parse("2014-12-01 00:00:00"), Time.parse("2014-12-01 01:00:00"), Time.parse("2014-12-01 02:00:00")]
>> DateDiscreter.discrete_hours(continuous_hours)
=> []
>> DateDiscreter.continuous_hours?(continuous_hours)
=> true

>> discrete_hours = [Time.parse("2014-12-01 00:00:00"), Time.parse("2014-12-01 02:00:00")]
>> DateDiscreter.discrete_hours(discrete_hours)
=> [Time.parse("2014-12-01 01:00:00")]
>> DateDiscreter.continuous_hours?(discrete_hours)
=> false

Contributing

  1. Fork it ( https://github.com/sue445/date_discreter/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Bitdeli Badge