Sha256: b75279422312124895c3ec916c7f96f10100256eabaea0c2bd17739a00ad2c1f

Contents?: true

Size: 895 Bytes

Versions: 37

Compression:

Stored size: 895 Bytes

Contents

module Chronic
  class MiniDate
    attr_accessor :month, :day

    def self.from_time(time)
      new(time.month, time.day)
    end

    def initialize(month, day)
      unless (1..12).include?(month)
        raise ArgumentError, "1..12 are valid months"
      end

      @month = month
      @day = day
    end

    def is_between?(md_start, md_end)
      return false if (@month == md_start.month && @month == md_end.month) &&
                      (@day < md_start.day || @day > md_end.day)
      return true if (@month == md_start.month && @day >= md_start.day) ||
                     (@month == md_end.month && @day <= md_end.day)

      i = (md_start.month % 12) + 1

      until i == md_end.month
        return true if @month == i
        i = (i % 12) + 1
      end

      return false
    end

    def equals?(other)
      @month == other.month and @day == other.day
    end
  end
end

Version data entries

37 entries across 37 versions & 7 rubygems

Version Path
gitlab-chronic-0.10.6 lib/chronic/mini_date.rb
gitlab-chronic-0.10.5 lib/chronic/mini_date.rb
asana2flowdock-1.0.0 vendor/bundle/ruby/1.9.1/gems/chronic-0.10.2/lib/chronic/mini_date.rb
chronic-mmlac-0.6.4.2 lib/chronic/mini_date.rb
chronic-mmlac-0.10.2.1 lib/chronic/mini_date.rb
chronic-0.10.2 lib/chronic/mini_date.rb
chronic-0.10.1 lib/chronic/mini_date.rb
chronic-0.10.0 lib/chronic/mini_date.rb
chronic-0.9.1 lib/chronic/mini_date.rb
chronic-0.9.0 lib/chronic/mini_date.rb
Hokkaido-0.1.5 chronic/lib/chronic/mini_date.rb
Hokkaido-0.1.4 chronic/lib/chronic/mini_date.rb
Hokkaido-0.1.3 chronic/lib/chronic/mini_date.rb
Hokkaido-0.1.2 chronic/lib/chronic/mini_date.rb
Hokkaido-0.1.1 chronic/lib/chronic/mini_date.rb
Hokkaido-0.1.0 chronic/lib/chronic/mini_date.rb
Hokkaido-0.0.9 chronic/lib/chronic/mini_date.rb
Hokkaido-0.0.6 chronic/lib/chronic/mini_date.rb
Hokkaido-0.0.5 chronic/lib/chronic/mini_date.rb
Hokkaido-0.0.4 chronic/lib/chronic/mini_date.rb