ice_cube 0.2.6 → 0.2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/ice_cube/rule.rb CHANGED
@@ -64,7 +64,6 @@ module IceCube
64
64
  # Set the time when this rule will no longer be effective
65
65
  def until(until_date)
66
66
  raise ArgumentError.new('Cannot specify until and count on the same rule') if @count #as per rfc
67
- raise ArgumentError.new('Argument must be a valid Time') unless until_date.class == Time
68
67
  @until_date = until_date
69
68
  self
70
69
  end
@@ -20,10 +20,11 @@ module IceCube
20
20
  protected
21
21
 
22
22
  def default_jump(date)
23
- date_utc = date.getutc
24
- next_month = date_utc.month + @interval
25
- difference = Time.utc(date_utc.year + (next_month - 1) / 12, (next_month - 1) % 12 + 1, date_utc.day, date_utc.hour, date_utc.min, date_utc.sec) - date
26
- adjust(date + difference, date)
23
+ goal = date
24
+ @interval.times do
25
+ goal += TimeUtil.days_in_month(goal) * ONE_DAY
26
+ end
27
+ adjust(goal, date)
27
28
  end
28
29
 
29
30
  private
@@ -21,10 +21,12 @@ module IceCube
21
21
 
22
22
  # one year from now, the same month and day of the year
23
23
  def default_jump(date)
24
- # calculate the difference in seconds of @interval years away and now
25
- date_utc = date.getutc
26
- difference = Time.utc(date_utc.year + @interval, date_utc.month, date_utc.day, date_utc.hour, date_utc.min, date_utc.sec) - date_utc
27
- adjust(date + difference, date)
24
+ #jump by months since there's no reliable way to jump by year
25
+ goal = date
26
+ (@interval * 12).times do
27
+ goal += TimeUtil.days_in_month(goal) * ONE_DAY
28
+ end
29
+ adjust(goal, date)
28
30
  end
29
31
 
30
32
  private
@@ -74,13 +74,11 @@ module IceCube
74
74
 
75
75
  # Add an individual date to this schedule
76
76
  def add_recurrence_date(date)
77
- raise ArgumentError.new('Argument must be a valid Time') unless date.class == Time
78
77
  @rdates << date
79
78
  end
80
79
 
81
80
  # Add an individual date exception to this schedule
82
81
  def add_exception_date(date)
83
- raise ArgumentError.new('Argument must be a valid Time') unless date.class == Time
84
82
  @exdates << date
85
83
  end
86
84
 
@@ -1,5 +1,5 @@
1
1
  module IceCube
2
2
 
3
- VERSION = "0.2.6"
3
+ VERSION = "0.2.6.1"
4
4
 
5
5
  end
metadata CHANGED
@@ -6,7 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 0
7
7
  - 2
8
8
  - 6
9
- version: 0.2.6
9
+ - 1
10
+ version: 0.2.6.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - John Crepezzi