Giter Site home page Giter Site logo

Can't find the docs?? about icalevents HOT 5 CLOSED

jazzband avatar jazzband commented on September 17, 2024 9
Can't find the docs??

from icalevents.

Comments (5)

devrosx avatar devrosx commented on September 17, 2024 1

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...

from icalevents.

tonimelisma avatar tonimelisma commented on September 17, 2024

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

from icalevents.

GrandMoff100 avatar GrandMoff100 commented on September 17, 2024

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

from icalevents.

jameselks avatar jameselks commented on September 17, 2024

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...

from icalevents.

GrandMoff100 avatar GrandMoff100 commented on September 17, 2024

Awesome! Thank you.

from icalevents.

Related Issues (20)

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.