Skip to content

Commit

Permalink
update recurrence with fixes to to_s method
Browse files Browse the repository at this point in the history
  • Loading branch information
mjreich committed Aug 11, 2010
1 parent 212fe32 commit 5ce59f1
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions lib/gcal4ruby/recurrence.rb
Expand Up @@ -78,10 +78,15 @@ def load(rec)
end
elsif key == 'INTERVAL'
@frequency[:inverval] = value.to_i
elsif key.include?("DTSTART;TZID")
elsif key.include?("DTSTART;TZID") or key.include?("DTSTART") or key.include?('DTSTART;VALUE=DATE-TIME')
@start_time = Time.parse_complete(value)
elsif key.include?("DTEND;TZID")
elsif key.include?('DTSTART;VALUE=DATE')
@start_time = Time.parse(value)
@all_day = true
elsif key.include?("DTEND;TZID") or key.include?("DTEND") or key.include?('DTEND;VALUE=DATE-TIME')
@end_time = Time.parse_complete(value)
elsif key.include?('DTEND;VALUE=DATE')
@end_time = Time.parse(value)
end
end
end
Expand Down Expand Up @@ -129,11 +134,10 @@ def to_s
end

#Returns a string with the correctly formatted ISO 8601 recurrence rule
def to_recurrence_string

output = ''
if @all_day
output += "DTSTART;VALUE=DATE:#{@start_time.utc.strftime("%Y%m%d")}\n"
def to_recurrence_string
output = ''
if @all_day
output += "DTSTART;VALUE=DATE:#{@start_time.utc.strftime("%Y%m%d")}\n"
else
output += "DTSTART;VALUE=DATE-TIME:#{@start_time.complete}\n"
end
Expand All @@ -157,8 +161,8 @@ def to_recurrence_string
else
value = v
end
f += "#{key.upcase};" if key != 'interval'
case key.downcase
f += "#{key.to_s.upcase};" if key != 'interval'
case key.to_s.downcase
when "secondly"
by += "BYSECOND=#{value};"
when "minutely"
Expand Down

0 comments on commit 5ce59f1

Please sign in to comment.