square / ruby-rrule

RRULE expansion for Ruby
Apache License 2.0
171 stars 25 forks source link

Parsing string from rrule npm lib fails #30

Open kirrg001 opened 3 years ago

kirrg001 commented 3 years ago

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!

suzumejakku commented 3 years ago

Hi,

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

suzumejakku commented 3 years ago

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.

gogvale commented 3 years ago

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
jfeaver commented 2 years ago

@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.