Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Change how monthly and yearly dates are calculated

  • Loading branch information...
commit 962eb4a50e9600e459214513e3c445a205a13c6d 1 parent 3c0306f
John Crepezzi authored
View
7 lib/ice_cube/rules/monthly_rule.rb
@@ -20,9 +20,10 @@ def to_ical
protected
def default_jump(date)
- date_type = date.utc? ? :utc : :local
- next_month = date.month + @interval
- Time.send(date_type, date.year + (next_month - 1) / 12, (next_month - 1) % 12 + 1, date.day, date.hour, date.min, date.sec)
+ date_utc = date.getutc
+ next_month = date_utc.month + @interval
+ 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
+ adjust(date + difference, date)
end
private
View
6 lib/ice_cube/rules/yearly_rule.rb
@@ -21,8 +21,10 @@ def to_ical
# one year from now, the same month and day of the year
def default_jump(date)
- date_type = date.utc? ? :utc : :local
- Time.send(date_type, date.year + @interval, date.month, date.day, date.hour, date.min, date.sec)
+ # calculate the difference in seconds of @interval years away and now
+ date_utc = date.getutc
+ difference = Time.utc(date_utc.year + @interval, date_utc.month, date_utc.day, date_utc.hour, date_utc.min, date_utc.sec) - date_utc
+ adjust(date + difference, date)
end
private
Please sign in to comment.
Something went wrong with that request. Please try again.