From 1cc223e56799244361c8fcc3421974eff9dbcc32 Mon Sep 17 00:00:00 2001 From: Yessiest Date: Wed, 2 Feb 2022 02:25:50 +0400 Subject: [PATCH] added event details --- README.md | 2 +- decal | 27 ++++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d5dd421..4c23e7a 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ This is a calendar app which tries to bring something new to the functionality o This project is currently very WIP, the todo list is: - [x] Basic decal functionality (receiving events and showing a tagged calendar) -- [ ] Event details +- [x] Event details - [ ] Creating events - [ ] Modifying events - [ ] Task lists diff --git a/decal b/decal index 978dd39..6b9195d 100755 --- a/decal +++ b/decal @@ -43,6 +43,12 @@ parser.add_argument("--create", parser.add_argument("--calendar", action="append", help="Specify a calendar (or multiple calendars) to sync from") +parser.add_argument("-d", + action="store_true", + help="Show event details for selected day") +parser.add_argument("-m", + action="store_true", + help="Show event details for entire month") parser.add_argument("-1", action="store_true", help="show only a single month (default)") @@ -56,9 +62,6 @@ parser.add_argument("-n", action="store", type=int, help="show n months") -parser.add_argument("-d", - action="store_true", - help="show event details") args = vars(parser.parse_args()) @@ -284,3 +287,21 @@ for count in range(3-(len(cal_prints)%3)): for cal in range(0,len(cal_prints),3): printlines(cal_prints[cal],cal_prints[cal+1],cal_prints[cal+2]) + +def printDailyEvents(events,evtrack=[]): + for event in events: + if not event in evtrack: + uid = event["uid"].encode() + print(colorize(event["dtstart"]+" - "+event["dtend"],uid)+":\n- "+event["summary"]) + evtrack.append(event) + +evtrack = [] +if args["d"]: + printDailyEvents(events[str(selected_date)],evtrack=evtrack) + exit(0) + +if args["m"]: + for day in range(*calendar.monthrange(args['year'],args['month'])): + key = str(date(args['year'],args['month'],day)) + if key in events: + printDailyEvents(events[key],evtrack=evtrack)