icalevents icon indicating copy to clipboard operation
icalevents copied to clipboard

Can't find the docs??

Open ghost opened this issue 6 years ago • 5 comments

As above, really - there's a two-line "usage" in README, but I can't find any documentation of how you actually use it..

ghost avatar Oct 08 '18 13:10 ghost

yes some simple test would be good, I want to fetch upcoming x days as list of events, but can't find any doc how to use this library...

devrosx avatar Mar 06 '19 15:03 devrosx

Hey @digitaltoast @devrosx did you find any documentation? Is there any way to use this library besides reading the source?

tonimelisma avatar Nov 29 '20 14:11 tonimelisma

Yeah, there isn't any documentation it seems... this is unfortunate. TIme to do some source reading I guess...

GrandMoff100 avatar May 30 '21 21:05 GrandMoff100

As a non-developer it took me a while to get my head around it.

Don't install with pip because the version is out of date. Clone this repository and add to your virtual environment using setup.py

Here's what I came up with:

from icalevents.icalevents import events
from datetime import datetime, timedelta
import pytz

url = 'https://outlook.office365.com/owa/calendar/....ics'

#Start and End need to be in UTC, see PR #108
my_timezone = pytz.timezone('Australia/Melbourne')
now = datetime.now().astimezone(pytz.timezone('UTC'))
future = (now + timedelta(hours=24)).astimezone(pytz.timezone('UTC'))

es = events(url, start=now, end=future)

#Return start date from event
def get_start(event):
    return event.start.astimezone(my_timezone)

#Sort events earliest to latest
es.sort(key=get_start)

#Move through each event and print something about it to terminal
for e in es:
    e.start = e.start.astimezone(my_timezone)
    e.end = e.end.astimezone(my_timezone)
    print(e.start.strftime("%Y-%m-%d %H:%M") + ' to ' + e.end.strftime("%Y-%m-%d %H:%M") + ' ' + e.summary )
   #You can see all of the object properties in icalparser.py - e.g. uid, summary description, start, end...

jameselks avatar Jun 30 '22 01:06 jameselks

Awesome! Thank you.

GrandMoff100 avatar Jun 30 '22 10:06 GrandMoff100

an example can be found here: https://icalevents.readthedocs.io/en/latest/

closing this old issue :-)

eigenmannmartin avatar Sep 09 '24 13:09 eigenmannmartin