Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Result discrepancy using RRule.js library on Android vs iOS #88

Closed
SApolinario opened this issue May 26, 2022 · 3 comments
Closed

Result discrepancy using RRule.js library on Android vs iOS #88

SApolinario opened this issue May 26, 2022 · 3 comments

Comments

@SApolinario
Copy link

Hi I quickly threw together a test to see if I could make use of the RRule.js library to process calendar event recurrence rules. The snippet below should return an array of strings representing UTC dates. However instead I get [{}, {}, {}, {}...] on Android and a comma separated list of dates on iOS. Am I missing a step in regards to parsing the actual result? Great library BTW =)

`JavascriptRuntime flutterJs = getJavascriptRuntime();

String ajvJS = await rootBundle.loadString("assets/js/rrule.min.js");
flutterJs.evaluate("""var window = global = globalThis;""");
flutterJs.evaluate(ajvJS + "");

var rruleIsLoaded = flutterJs
    .evaluate("""var rruleIsLoaded = (typeof rrule == 'undefined') ? 
      "0" : "1"; rruleIsLoaded;
    """).stringResult;
print("RRule is Loaded $rruleIsLoaded");

var expression = """const rule = rrule.rrulestr('DTSTART:20120201T093000Z\\nRRULE:FREQ=WEEKLY;INTERVAL=5;UNTIL=20130130T230000Z;BYDAY=MO,FR')""";
flutterJs.evaluate(expression);

JsEvalResult result = flutterJs.evaluate("""rule.between(new Date(Date.UTC(2012, 1, 1)), new Date(Date.UTC(2013, 1, 1)))""");

print(result);`
@SApolinario
Copy link
Author

I got it working. I switched to using JavascriptCore on Android and I also JSON.stringify the result before passing it back to dart.

@shilangyu
Copy link
Contributor

I got it working

Can this be closed then?

@SApolinario
Copy link
Author

Yes, it can be closed. Sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants