rrule icon indicating copy to clipboard operation
rrule copied to clipboard

the `until` parser throws an error on hermes

Open rkstar opened this issue 1 year ago • 0 comments

Reporting an issue

  • [x] The version of rrule you are using -- 2.7.2
  • [x] Your operating system -- Expo SDK 47 w/hermes enabled (react native)
  • [x] Your local timezone (run $ date from the command line of the machine showing the bug) -- Mon 8 May 2023 15:58:44 EDT

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]

rkstar avatar May 08 '23 20:05 rkstar