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

[docs][calendar] Updating Calendar RecurrenceRule types and docs to functional values #7488

Closed
wants to merge 1 commit into from
Closed

[docs][calendar] Updating Calendar RecurrenceRule types and docs to functional values #7488

wants to merge 1 commit into from

Conversation

rschneid0
Copy link

This is a change from ts expecting and the docs specifying a string as the endDate of a RecurrenceRule to a number.

Why

The current calendar docs on recurrence rules are slightly inaccurate.
See #7399 for details

How

I just changed the expected type of the RecurrenceRule endDate from string to number and updated the docs accordingly.

Test Plan

This is my first PR so I'm not sure if I've touched all the appropriate files! If there's anything out of place or incomplete please let me know

@rschneid0 rschneid0 changed the title [docs] Updating Calendar RecurrenceRule type and docs to functional values [docs][calendar] Updating Calendar RecurrenceRule type and docs to functional values Mar 26, 2020
@rschneid0 rschneid0 changed the title [docs][calendar] Updating Calendar RecurrenceRule type and docs to functional values [docs][calendar] Updating Calendar RecurrenceRule types and docs to functional values Mar 26, 2020
…ng ts typing from expecting a string to a number
@lukmccall
Copy link
Contributor

Hi, @rschneid0. I'm not sure if endDate should be a number. The calendar has code that should handle 3 types: number, Date object or a string (in ISO format).

Code for reference:

  • Handling strings or numbers:

    + (NSDate *)NSDate:(id)json
    {
    if ([json isKindOfClass:[NSNumber class]]) {
    return [NSDate dateWithTimeIntervalSince1970:[json doubleValue] / 1000.0];
    } else if ([json isKindOfClass:[NSString class]]) {
    static NSDateFormatter *formatter;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
    formatter = [NSDateFormatter new];
    formatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ";
    formatter.locale = [NSLocale localeWithLocaleIdentifier:@"en_US_POSIX"];
    formatter.timeZone = [NSTimeZone timeZoneWithName:@"UTC"];
    });
    NSDate *date = [formatter dateFromString:json];
    if (!date) {
    UMLogError(@"JSON String '%@' could not be interpreted as a date. "
    "Expected format: YYYY-MM-DD'T'HH:mm:ss.sssZ", json);
    }
    return date;
    } else if (json) {
    UMLogError(json, @"a date");
    }
    return nil;
    }

  • Handling Date objects:

    function stringifyIfDate(date: any): any {
    return date instanceof Date ? date.toISOString() : date;
    }

So, I don't think that is a correct fix for this problem. Please check this one #7527. It should fix this bug.

@lukmccall lukmccall closed this Mar 30, 2020
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

Successfully merging this pull request may close these issues.

None yet

3 participants