square/ruby-rrule

Parsing string from rrule npm lib fails

kirrg001 opened this issue · 4 comments

Hi there!

I am using the npm library https://github.com/jakubroztocil/rrule

I am receiving the following rrule string

DTSTART:20201020T000000Z\nRRULE:FREQ=WEEKLY;BYHOUR=2;BYMINUTE=0;BYDAY=WE

I am unable to parse this string.
Getting

RRule::InvalidRRule (Valid FREQ value is required)

I assume this gem doesn't support this format? Although this is the official rrule format I think.

Thanks so much for this gem!

Hi,

I have the exact same issue. Did you find any way around this ? It is a pity, as this gem is quite elegant...

Hi,

I have the exact same issue. Did you find any way around this ? It is a pity, as this gem is quite elegant...

For now I parse the string I receive from rrule.js, and send the two pieces (dtstart and rrule) to ruby-rrule's RRule.parse. It works but it is not as clean as it could be.

Hi,

I have the exact same issue. Did you find any way around this ? It is a pity, as this gem is quite elegant...

Yes.

unless params[:photoflow][:rrule].blank?
  rrule = params[:photoflow][:rrule]
          .gsub('RRULE:', '')
          .gsub("\n", "\;")
  params[:photoflow][:rrule] = rrule
end

@rmitchell-sq: The prefix that needs to be dropped here is part of the RRULE specification:

rrule      = "RRULE" rrulparam ":" recur CRLF

Has the team considered removing that, if present, during the parse?

Here's my workaround. At the top of the Ruby file in which I parse an RRULE string I add using RRule::Parse and then RRule.parse(...) works as expected, even if my rrule string has been prepared by rrule.js.