jkbrzt / rrule

JavaScript library for working with recurrence rules for calendar dates as defined in the iCalendar RFC and more.
https://jkbrzt.github.io/rrule
Other
3.24k stars 506 forks source link

the `until` parser throws an error on hermes #579

Open rkstar opened 1 year ago

rkstar commented 1 year ago

Reporting an issue

React Native now defaults to using the hermes js engine which messes up a lot of Date related functionality because it's much more strict on the input it will accept. It seems that the usage of Date.parse in the until code here has been exposed. When passing in a string to the fromText function, I get an error that my input is invalid. The reason is because the input being passed to Date.parse contains a leading space character and Date.parse (in hermes) doesn't know how to deal with this.

Here is the line of code: https://github.com/jakubroztocil/rrule/blob/35d819ffdd4558335b1a66ffc1f2488149885da6/src/nlp/parsetext.ts#L426

The solution is to add .trim() to the value being provided to Date.parse.

Input:

const rruleFromString = RRule.fromText("Every 1 days until 2023-05-10T04:00:00.000Z");

Expected output: an rrule object

Actual output:

 WARN  Warning: An unhandled error was caught from submitForm() [Error: Cannot parse until date: 2023-05-10T04:00:00.000Z]