Skip to content

Commit

Permalink
[expo-calendar] Fix recurrence rule and event parsing (#7527)
Browse files Browse the repository at this point in the history
* [expo-calendar] Fix date parsing

* [expo-calendar] Add test

* [expo-calendar] Add changelog
  • Loading branch information
lukmccall committed May 13, 2020
1 parent 335e67a commit d091b48
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
13 changes: 13 additions & 0 deletions apps/test-suite/tests/Calendar.js
Expand Up @@ -337,6 +337,19 @@ export async function test(t) {
t.expect(typeof eventId).toBe('string');
});

t.it('creates an event with the recurrence rule', async () => {
const eventId = await createTestEventAsync(calendarId, {
recurrenceRule: {
endDate: new Date(2019, 3, 5),
frequency: 'daily',
interval: 1,
},
});

t.expect(eventId).toBeDefined();
t.expect(typeof eventId).toBe('string');
});

if (Platform.OS === 'ios') {
t.it('rejects when time zone is invalid', async () => {
let error;
Expand Down
1 change: 1 addition & 0 deletions packages/expo-calendar/CHANGELOG.md
Expand Up @@ -9,3 +9,4 @@
### 🐛 Bug fixes

- Fixed `Calendar.getCalendarsAsync` requiring not needed permissions on iOS. ([#7928](https://github.com/expo/expo/pull/7928) by [@lukmccall](https://github.com/lukmccall))
- Fix `recurrence rule` and `event` parsing. ([#7527](https://github.com/expo/expo/pull/7527) by [@lukmccall](https://github.com/lukmccall))
6 changes: 5 additions & 1 deletion packages/expo-calendar/build/Calendar.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/expo-calendar/build/Calendar.js.map

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion packages/expo-calendar/src/Calendar.ts
Expand Up @@ -701,7 +701,11 @@ function stringifyIfDate(date: any): any {

function stringifyDateValues(obj: object): object {
return Object.keys(obj).reduce((acc, key) => {
acc[key] = stringifyIfDate(obj[key]);
const value = obj[key];
if (typeof value === 'object' && !(value instanceof Date)) {
return { ...acc, [key]: stringifyDateValues(value) };
}
acc[key] = stringifyIfDate(value);
return acc;
}, {});
}

0 comments on commit d091b48

Please sign in to comment.