Code Monkey home page Code Monkey logo

enough_icalendar's People

Contributors

martingeorgiu avatar robert-virkus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

enough_icalendar's Issues

Not compatible with Google Calendar

When trying to parse the Google Calendar Response the following error occurs;

Flutter Version; 2.2.3
Tried in Chrome

No property implementation found for X-WR-CALNAME:{email}@gmail.com
Error: FormatException: Invalid duration: P0DT3H0M0S (for part [0DT3H0])
at Object.throw_ [as throw] (http://localhost:62444/dart_sdk.js:5041:11)
at Function._parseSection (http://localhost:62444/packages/enough_icalendar/src/components.dart.lib.js:7659:19)
at Function.parse (http://localhost:62444/packages/enough_icalendar/src/components.dart.lib.js:7744:46)
at Function._parsePropertyValue (http://localhost:62444/packages/enough_icalendar/src/components.dart.lib.js:3509:36)
at properties.TriggerProperty.new.properties.Property.new (http://localhost:62444/packages/enough_icalendar/src/components.dart.lib.js:3812:40)
at new properties.TriggerProperty.new (http://localhost:62444/packages/enough_icalendar/src/components.dart.lib.js:5068:46)
at Function.parseProperty (http://localhost:62444/packages/enough_icalendar/src/components.dart.lib.js:3691:18)
at Function.parseLines (http://localhost:62444/packages/enough_icalendar/src/components.dart.lib.js:1495:46)
at Function.parse (http://localhost:62444/packages/enough_icalendar/src/components.dart.lib.js:1473:36)
at getPrivateCalendar (http://localhost:62444/packages/home_control/calendar/data/data_sources/calendar_data_source.dart.lib.js:67:71)
at getPrivateCalendar.next ()
at http://localhost:62444/dart_sdk.js:37403:33
at _RootZone.runUnary (http://localhost:62444/dart_sdk.js:37274:59)
at _FutureListener.thenAwait.handleValue (http://localhost:62444/dart_sdk.js:32530:29)
at handleValueCallback (http://localhost:62444/dart_sdk.js:33057:49)
at Function._propagateToListeners (http://localhost:62444/dart_sdk.js:33095:17)
at _Future.new.[_completeWithValue] (http://localhost:62444/dart_sdk.js:32943:23)
at async._AsyncCallbackEntry.new.callback (http://localhost:62444/dart_sdk.js:32964:35)
at Object._microtaskLoop (http://localhost:62444/dart_sdk.js:37526:13)
at startMicrotaskLoop (http://localhost:62444/dart_sdk.js:37532:13)
at http://localhost:62444/dart_sdk.js:33303:9
No property implementation found for X-WR-CALNAME:{email}@gmail.com
Error: FormatException: Invalid duration: P0DT3H0M0S (for part [0DT3H0])
at Object.throw
[as throw] (http://localhost:62444/dart_sdk.js:5041:11)
at Function._parseSection (http://localhost:62444/packages/enough_icalendar/src/components.dart.lib.js:7659:19)
at Function.parse (http://localhost:62444/packages/enough_icalendar/src/components.dart.lib.js:7744:46)
at Function._parsePropertyValue (http://localhost:62444/packages/enough_icalendar/src/components.dart.lib.js:3509:36)
at properties.TriggerProperty.new.properties.Property.new (http://localhost:62444/packages/enough_icalendar/src/components.dart.lib.js:3812:40)
at new properties.TriggerProperty.new (http://localhost:62444/packages/enough_icalendar/src/components.dart.lib.js:5068:46)
at Function.parseProperty (http://localhost:62444/packages/enough_icalendar/src/components.dart.lib.js:3691:18)
at Function.parseLines (http://localhost:62444/packages/enough_icalendar/src/components.dart.lib.js:1495:46)
at Function.parse (http://localhost:62444/packages/enough_icalendar/src/components.dart.lib.js:1473:36)
at getPrivateCalendar (http://localhost:62444/packages/home_control/calendar/data/data_sources/calendar_data_source.dart.lib.js:67:71)
at getPrivateCalendar.next ()
at http://localhost:62444/dart_sdk.js:37403:33
at _RootZone.runUnary (http://localhost:62444/dart_sdk.js:37274:59)
at _FutureListener.thenAwait.handleValue (http://localhost:62444/dart_sdk.js:32530:29)
at handleValueCallback (http://localhost:62444/dart_sdk.js:33057:49)
at Function._propagateToListeners (http://localhost:62444/dart_sdk.js:33095:17)
at _Future.new.[_completeWithValue] (http://localhost:62444/dart_sdk.js:32943:23)
at async._AsyncCallbackEntry.new.callback (http://localhost:62444/dart_sdk.js:32964:35)
at Object._microtaskLoop (http://localhost:62444/dart_sdk.js:37526:13)
at _startMicrotaskLoop (http://localhost:62444/dart_sdk.js:37532:13)
at http://localhost:62444/dart_sdk.js:33303:9

RRULE always appends `;WKST1` which breaks macOS Calendar recurrence

Great package, the only one on pub.dev I've found so far that allows me to parse a text recurrence rule into the model.

Unfortunately, the output RRULE value always ends in ;WKST1 or the int value of weekday that is passed to startOfWorkWeek constructor.

If supplied at all, the output format should be WKST= + the two-letter day of week, like so:
;WKST=SU

This additionally results in the side-effect that Recurrence.parse(rrule) does not parse the generated WKST value correctly, as parse expects the two-letter day of week.

There is no output workaround except:

final vCalendar = VCalendar.createEvent(...);
vCalendar.event?.recurrenceRule = Recurrence.parse(rrule!);
final iCal = vCal.toString().replaceAll(';WKST1', ';WKST=SU');

This workaround must be done in order to get macOS Calendar (and possibly iOS Calendar, I haven't tested), to recognize a recurring event, because it does not tolerate the malformed WKST parameter.

There is no parsing workaround except replacing WKST1 with WKST=SU (or other day of week) before calling parse.

How can I convert Dart `Duration` to `IsoDuration`?

Help wanted

I don't really know IsoDuration format and how to convert it to Dart Duration.
So I was looking for a Duration.toIsoDuration() function in the source code, but I didn't.

Would you like to provide an extension function, a named/factory constructor, or a static function to convert Duration object to IsoDuration object? That would be very helpful.

FormatException: Unknown component.

Unable to parse ics from Formula 1

This is my ics url: https://ics.ecal.com/ecal-sub/65d5e5b6532bea0008b2ee55/Formula%201.ics

The error:

flutter: FormatException: Unknown component: BEGIN:VCALENDAR
PRODID:-//E-DIARY//E-DIARY 1.0//EN
VERSION:2.0
METHOD:PUBLISH
X-WR-CALNAME:Formula 1
X-Built-On-Cache-Miss:true
BEGIN:VEVENT
LAST-MODIFIED:20240221T122324Z
DTSTAMP:20240221T122324Z
LOCATION:Monaco
X-ECAL-SCHEDULE:63ed7aff4c410f0d70163027
DTSTART:20240524T113000Z
DTEND:20240524T123000Z
SUMMARY:๐ŸŽ FORMULA 1 GRAND PRIX DE MONACO 2024 - Practice 1
TRANSP:TRANSPARENT
SEQUENCE:0
UID:65af54f4f4b46e5026018b20
PRIORITY:5
X-MICROSOFT-CDO-IMPORTANCE:1
CLASS:PUBLIC
DESCRIPTION:Follow all the action on F1 TV and F1.com. \n\nUnlock the insid
 e world of F1 by signing up to F1 Unlocked at F1.com/F1Unlocked\n\nFollow 
 on the go with F1 TV\nhttps://cal.f1.com/f/pdgKx/2kxXC\n\nVisit the Race H
 ub\nhttps://cal.f1.com/f/pdgKF/2kxXC\n\nFree sign up to F1 Unlocked\nhttps
 ://cal.f1.com/f/pdgKP/2kxXC\n\nDownload the Official F1 Race Programme App
 \nhttps://cal.f1.com/f/pdgL1/2kxXC\n\nWear your favourite teams colours wi
 th F1 store\nhttps://cal.f1.com<โ€ฆ>

Stacktrace:

flutter: #0      VComponent._createComponent (package:enough_icalendar/src/components.dart:278:9)
#1      VComponent.parseLines (package:enough_icalendar/src/components.dart:210:18)
#2      VComponent.parse (package:enough_icalendar/src/components.dart:200:12)
#3      WebCalUtil.parseWebCal (package:impaktfull_f1/util/webcal/webcal_util.dart:90:34)
<asynchronous suspension>
#4      WebCalUtil.syncRacesWithWebCal (package:impaktfull_f1/util/webcal/webcal_util.dart:18:20)
<asynchronous suspension>
#5      _RaceRepository.syncRaces (package:impaktfull_f1/repo/race/race_repository.dart:161:28)
<asynchronous suspension>
#6      AdminViewModel.onSyncRacesTapped (package:impaktfull_f1/viewmodel/admin/admin_viewmodel.dart:29:22)
<asynchronous suspension>
#7      _ImpaktfullListItemState._onAsyncTap (package:impaktfull_ui/src/components/list_item/impaktfull_list_item.dart:70:7)
<asynchronous suspension>

This is my code to parse it.


  Future<List<WebCalEvent>> parseWebCal(String url) async {
    final httpUrl = url.replaceFirst('webcal://', 'https://');
    final data = await dio.get(httpUrl);
    if (data.statusCode != 200) {
      throw Exception('Failed to load webcal (${data.statusCode})');
    }
    final icsString = data.data as String;
    final icalendar = VComponent.parse(
      icsString,
    );
    if (icalendar is! VCalendar) throw Exception('Failed to parse webcal');
    final events = icalendar.children
        .map((element) {
          if (element is! VEvent) return null;
          final summary = element.summary;
          final startDate = element.start;
          final endDate = element.end;
          if (summary == null) return null;
          if (startDate == null) return null;
          if (endDate == null) return null;
          return WebCalEvent(
            title: summary,
            startDate: startDate,
            endDate: endDate,
          );
        })
        .whereType<WebCalEvent>()
        .toList();
    return events;
  }

class WebCalEvent {
  final String title;
  final DateTime startDate;
  final DateTime endDate;

  const WebCalEvent({
    required this.title,
    required this.startDate,
    required this.endDate,
  });
}

Is there a way to add custom parsers?

I added a custom property, but I keep getting this error when adding the property to a component.

No property implementation found for X-CALENDAR-ID:1

I tried to fix this by providing a custom parser on VComponent.parse(ical, customParser: (name, definition) {}), but this does not seem to get used. Is there any way to register properties without having to edit the code directly?

Setting VAlarm.triggerDate throws FormatException

Minimal reproducible example

import 'package:enough_icalendar/enough_icalendar.dart';

void main(){
  final alarm = VAlarm();
  alarm.triggerDate = DateTime.now();
}

Result:

FormatException: duration content needs to start with P, 20231227T025525 is invalid
#0      IsoDuration.parse (package:enough_icalendar/src/types.dart:1460:7)
#1      Property._parsePropertyValue (package:enough_icalendar/src/properties.dart:201:28)
#2      new Property (package:enough_icalendar/src/properties.dart:17:11)
#3      new TriggerProperty (package:enough_icalendar/src/properties.dart:1372:40)
#4      TriggerProperty.createWithDateTime (package:enough_icalendar/src/properties.dart:1404:9)
#5      VAlarm.triggerDate= (package:enough_icalendar/src/components.dart:1776:53)

UTC time not correctly parsed

The F1 ics returns utc date times:

DTSTART:20240302T150000Z
DTEND:20240302T170000Z
SUMMARY:๐Ÿ FORMULA 1 GULF AIR BAHRAIN GRAND PRIX 2024 - Race

URL: webcal://ics.ecal.com/ecal-sub/65d5e5b6532bea0008b2ee55/Formula%201.ics

But they are not parsed correctly. They are parsed as local time. I live in belgium so I get:

20240302T150000
20240302T170000

If I convert this to utc it becomes:

20240302T150000Z
20240302T160000Z

The output for my local time should be:

20240302T160000
20240302T180000

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.