diff --git a/App/Extensions/Foundation+Extensions.swift b/App/Extensions/Foundation+Extensions.swift index 53f3121b..2989b823 100644 --- a/App/Extensions/Foundation+Extensions.swift +++ b/App/Extensions/Foundation+Extensions.swift @@ -36,9 +36,15 @@ extension ISO8601DateFormatter { } } - // If the string already includes a timezone, don't guess with local-time parsing. + // If the string already includes a timezone suffix on a *time* component, + // don't guess with local-time parsing. We must NOT run this check on a + // bare `yyyy-MM-dd` because the trailing `-DD` would match the + // `[+-]\d{2}` branch of this regex and falsely classify the day as a + // timezone offset, causing the parser to bail before trying the + // `yyyy-MM-dd` fallback below. let hasTimeZoneInfo = - dateString.range( + dateString.count > 10 + && dateString.range( of: #"([Zz]|[+-]\d{2}(:?\d{2})?)$"#, options: .regularExpression ) != nil diff --git a/App/Services/Calendar.swift b/App/Services/Calendar.swift index 1a58890d..161c084a 100644 --- a/App/Services/Calendar.swift +++ b/App/Services/Calendar.swift @@ -216,7 +216,11 @@ final class CalendarService: Service { events = events.filter { ($0.hasRecurrenceRules) == isRecurring } } - return events.map { Event($0) } + return events.map { event -> Event in + var e = Event(event) + e.identifier = event.eventIdentifier + return e + } } Tool( name: "events_create", @@ -533,7 +537,9 @@ final class CalendarService: Service { // Save the event try self.eventStore.save(event, span: .thisEvent) - return Event(event) + var result = Event(event) + result.identifier = event.eventIdentifier + return result } } }