jkbrzt / rrule

JavaScript library for working with recurrence rules for calendar dates as defined in the iCalendar RFC and more.

Home Page:https://jkbrzt.github.io/rrule

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Possible solution for "Invalid UNTIL value"

msageryd opened this issue · comments

I have seen a couple of issues related to Invalid UNTIL value, and thought I'd post my problem and solution for others to find. I'll close this issue directly, since it's not a real issue.

My problem:
I stored my rrule strings in Postgres. It's possible to store escaped strings with the E prefix in Postgres, but this is cumbersome.

If you store your rrule strings as they are in Postgres, you might end up with the characters \ and n instead of a newLine char, i.e. char(10)

This is not a valid rrule string, since the \n is just a backslash and an n: 20231001T033900Z\nRRULE:FREQ=DAILY.
rrule will give you Invalid UNTIL value if you try to put this string into rrulestr()

To solve this in Node you can replace the string "\n" wich char(10) like this:

const newLineRegex = /\\n/g;
rruleString = rruleString.replace(newLineRegex, String.fromCharCode(10));

I hope I can save others from ripping their hair over this as I did.