We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
this JSONencoder will properly handle icalendar.props and datetime items
I am contributing this in case anyone else needs it.
perhaps it can be added into props.py.
from json import JSONEncoder import json from datetime import datetime from icalendar import Calendar, vDDDTypes, Event class ICalendarEncoder(JSONEncoder): def default(self, obj, markers=None): try: if obj.__module__.startswith("icalendar.prop"): return (obj.to_ical()) except AttributeError: pass if isinstance(obj, datetime): return (obj.now().strftime('%Y-%m-%dT%H:%M:%S')) return JSONEncoder.default(self,obj) cal = Calendar.from_ical(open('test.ics','rb').read()) for event in cal.walk(name="VEVENT"): suspect = json.dumps(event, cls=ICalendarEncoder) working = json.loads(suspect)
The text was updated successfully, but these errors were encountered:
i added this to props.py and submitted it as a pull request
Sorry, something went wrong.
@rbpasker would you be okay with us adding this little program as an example script?
encode events to JSON using collective/icalendar#85 as a guide
0ede4ad
No branches or pull requests
this JSONencoder will properly handle icalendar.props and datetime items
I am contributing this in case anyone else needs it.
perhaps it can be added into props.py.
The text was updated successfully, but these errors were encountered: