Skip to content

Instantly share code, notes, and snippets.

@SpEcHiDe
Created December 22, 2016 15:12
Show Gist options
  • Save SpEcHiDe/a586661b559f5454444903c7fec5c23f to your computer and use it in GitHub Desktop.
Save SpEcHiDe/a586661b559f5454444903c7fec5c23f to your computer and use it in GitHub Desktop.
Prepare Timetable NITC only
#!/usr/bin/env python2
#
# 1. slots ?
# 2. process
# 3. output CSV
#
def create_ICS_from_slots(slots) :
'''
works only for NITC students
'''
template = '''
BEGIN:VCALENDAR
PRODID:-//Google Inc//Google Calendar 70.9054//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
'''
# X-WR-CALNAME:magicteacher95@gmail.com
template += '''
X-WR-TIMEZONE:Asia/Calcutta
BEGIN:VTIMEZONE
TZID:Asia/Calcutta
X-LIC-LOCATION:Asia/Calcutta
BEGIN:STANDARD
TZOFFSETFROM:+0530
TZOFFSETTO:+0530
TZNAME:+0530
DTSTART:19700101T000000
END:STANDARD
END:VTIMEZONE
'''
if 'P' in slots :
template += "BEGIN:VEVENT"
template += "DTSTART;TZID=Asia/Calcutta:20161226T140000"
template += "DTEND;TZID=Asia/Calcutta:20161226T170000"
template += "RRULE:FREQ=WEEKLY;UNTIL=20170407T153000Z;BYDAY=WE"
# template += "EXDATE;TZID=Asia/Calcutta:20150211T140000"
# template += "EXDATE;TZID=Asia/Calcutta:20150408T140000"
# I think this date is when I exported my calendar for getting a template
# template += "DTSTAMP:20161222T144529Z"
template += "UID:ir85l30hr67bkabttq2fmarvak@google.com"
# the current created date
template += "CREATED:20161222T080030Z"
# a one line description
template += "DESCRIPTION: this might will appear in SMS "
# provided that you have turned on SMS and description is less than 25 words
template += "LOCATION:"
template += "SEQUENCE:1"
template += "STATUS:CONFIRMED"
# detailed summary
template += "SUMMARY: detailed summary will appear in Calendar"
template += "TRANSP:OPAQUE"
template += "END:VEVENT"
if 'Q' in slots :
template += "BEGIN:VEVENT"
template += "DTSTART;TZID=Asia/Calcutta:20161227T140000"
template += "DTEND;TZID=Asia/Calcutta:20161227T170000"
template += "RRULE:FREQ=WEEKLY;UNTIL=20170407T153000Z;BYDAY=WE"
# template += "EXDATE;TZID=Asia/Calcutta:20150211T140000"
# template += "EXDATE;TZID=Asia/Calcutta:20150408T140000"
# I think this date is when I exported my calendar for getting a template
# template += "DTSTAMP:20161222T144529Z"
template += "UID:ir85l30hr67bkabttq2fmarvak@google.com"
# the current created date
template += "CREATED:20161222T080030Z"
# a one line description
template += "DESCRIPTION: this might will appear in SMS "
# provided that you have turned on SMS and description is less than 25 words
template += "LOCATION:"
template += "SEQUENCE:1"
template += "STATUS:CONFIRMED"
# detailed summary
template += "SUMMARY: detailed summary will appear in Calendar"
template += "TRANSP:OPAQUE"
template += "END:VEVENT"
if 'R' in slots :
template += "BEGIN:VEVENT"
template += "DTSTART;TZID=Asia/Calcutta:20161228T140000"
template += "DTEND;TZID=Asia/Calcutta:20161228T170000"
template += "RRULE:FREQ=WEEKLY;UNTIL=20170407T153000Z;BYDAY=WE"
# template += "EXDATE;TZID=Asia/Calcutta:20150211T140000"
# template += "EXDATE;TZID=Asia/Calcutta:20150408T140000"
# I think this date is when I exported my calendar for getting a template
# template += "DTSTAMP:20161222T144529Z"
template += "UID:ir85l30hr67bkabttq2fmarvak@google.com"
# the current created date
template += "CREATED:20161222T080030Z"
# a one line description
template += "DESCRIPTION: this might will appear in SMS "
# provided that you have turned on SMS and description is less than 25 words
template += "LOCATION:"
template += "SEQUENCE:1"
template += "STATUS:CONFIRMED"
# detailed summary
template += "SUMMARY: detailed summary will appear in Calendar"
template += "TRANSP:OPAQUE"
template += "END:VEVENT"
if 'S' in slots :
template += "BEGIN:VEVENT"
template += "DTSTART;TZID=Asia/Calcutta:20161222T140000"
template += "DTEND;TZID=Asia/Calcutta:20161222T170000"
template += "RRULE:FREQ=WEEKLY;UNTIL=20170407T153000Z;BYDAY=WE"
# template += "EXDATE;TZID=Asia/Calcutta:20150211T140000"
# template += "EXDATE;TZID=Asia/Calcutta:20150408T140000"
# I think this date is when I exported my calendar for getting a template
# template += "DTSTAMP:20161222T144529Z"
template += "UID:ir85l30hr67bkabttq2fmarvak@google.com"
# the current created date
template += "CREATED:20161222T080030Z"
# a one line description
template += "DESCRIPTION: this might will appear in SMS "
# provided that you have turned on SMS and description is less than 25 words
template += "LOCATION:"
template += "SEQUENCE:1"
template += "STATUS:CONFIRMED"
# detailed summary
template += "SUMMARY: detailed summary will appear in Calendar"
template += "TRANSP:OPAQUE"
template += "END:VEVENT"
if 'T' in slots :
template += "BEGIN:VEVENT"
template += "DTSTART;TZID=Asia/Calcutta:20161223T140000"
template += "DTEND;TZID=Asia/Calcutta:20161223T170000"
template += "RRULE:FREQ=WEEKLY;UNTIL=20170407T153000Z;BYDAY=WE"
# template += "EXDATE;TZID=Asia/Calcutta:20150211T140000"
# template += "EXDATE;TZID=Asia/Calcutta:20150408T140000"
# I think this date is when I exported my calendar for getting a template
# template += "DTSTAMP:20161222T144529Z"
template += "UID:ir85l30hr67bkabttq2fmarvak@google.com"
# the current created date
template += "CREATED:20161222T080030Z"
# a one line description
template += "DESCRIPTION: this might will appear in SMS "
# provided that you have turned on SMS and description is less than 25 words
template += "LOCATION:"
template += "SEQUENCE:1"
template += "STATUS:CONFIRMED"
# detailed summary
template += "SUMMARY: detailed summary will appear in Calendar"
template += "TRANSP:OPAQUE"
template += "END:VEVENT"
template += '''
END:VCALENDAR
'''
print(template)
def main() :
slots = raw_input("enter your slots, seperated by ,: ").split(',')
print(slots)
ics = create_ICS_from_slots(slots)
print(ics)
if __name__ == "__main__" :
main()
print("hello")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment