diff --git a/decal b/decal index fa3d947..181d3c3 100755 --- a/decal +++ b/decal @@ -54,6 +54,9 @@ 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()) @@ -89,10 +92,7 @@ if config['DEFAULT']['uri'] == "your caldav server here": #generate the actual calendar, line by line, output an array of lines. #it works trust me, idk what is happening in this one but it works. -def gencal(year,month,start_on_sunday=True,cell_modifier=lambda d: d,append_year=True): - firstweekday = 0 - if start_on_sunday: - firstweekday = 6 +def gencal(year,month,firstweekday=6,cell_modifier=lambda d: d,append_year=True): cal = calendar.Calendar(firstweekday=firstweekday) lines = [""]*6 monthstart = False @@ -108,14 +108,11 @@ def gencal(year,month,start_on_sunday=True,cell_modifier=lambda d: d,append_year lines[counter//7] += " " lines[counter//7] +=" " counter+=1 - month = datetime.date(year,month,1).strftime("%B %Y") - padding = (21-len(month))//2 - rpadding = 21%(padding+len(month)+padding) - if start_on_sunday: - lines.insert(0,"Su Mo Tu We Th Fr Sa ") - else: - lines.insert(0,"Mo Tu We Th Fr Sa Su ") - lines.insert(0,(" "*padding)+month+(" "*(padding+rpadding))) + weeklines = ["Mo","Tu","We","Th","Fr","Sa","Su"] + for times in range(firstweekday): + weeklines.append(weeklines.pop(0)) + lines.insert(0," ".join(weeklines)+" ") + lines.insert(0,datetime.date(year,month,1).strftime("%B %Y").center(21)) lines[-1] += " "*(21-len(lines[-1])) return lines @@ -225,8 +222,6 @@ for cal in calendars: if not curdate.day in events[curdindex]: events[curdindex][curdate.day] = [] events[curdindex][curdate.day].append(event) - else: - break curdate += datetime.timedelta(days=1) # if you're reading the source code for this (oof), feel free to suggest improvements for this, or, well, anything above or below this comment (as long as it's not just "rewrite this entire thing in C++ for me because i think python bad", "idk how but optimize stuff kthx". just don't be a dick, ok? thanks).