slowly making things better

This commit is contained in:
Yessiest 2022-02-01 23:43:52 +04:00
parent 3221d2df5e
commit 038fbd0f9f
1 changed files with 9 additions and 14 deletions

23
decal
View File

@ -54,6 +54,9 @@ parser.add_argument("-n",
action="store", action="store",
type=int, type=int,
help="show n months") help="show n months")
parser.add_argument("-d",
action="store_true",
help="show event details")
args = vars(parser.parse_args()) 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. #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. #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): def gencal(year,month,firstweekday=6,cell_modifier=lambda d: d,append_year=True):
firstweekday = 0
if start_on_sunday:
firstweekday = 6
cal = calendar.Calendar(firstweekday=firstweekday) cal = calendar.Calendar(firstweekday=firstweekday)
lines = [""]*6 lines = [""]*6
monthstart = False 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] += " "
lines[counter//7] +=" " lines[counter//7] +=" "
counter+=1 counter+=1
month = datetime.date(year,month,1).strftime("%B %Y") weeklines = ["Mo","Tu","We","Th","Fr","Sa","Su"]
padding = (21-len(month))//2 for times in range(firstweekday):
rpadding = 21%(padding+len(month)+padding) weeklines.append(weeklines.pop(0))
if start_on_sunday: lines.insert(0," ".join(weeklines)+" ")
lines.insert(0,"Su Mo Tu We Th Fr Sa ") lines.insert(0,datetime.date(year,month,1).strftime("%B %Y").center(21))
else:
lines.insert(0,"Mo Tu We Th Fr Sa Su ")
lines.insert(0,(" "*padding)+month+(" "*(padding+rpadding)))
lines[-1] += " "*(21-len(lines[-1])) lines[-1] += " "*(21-len(lines[-1]))
return lines return lines
@ -225,8 +222,6 @@ for cal in calendars:
if not curdate.day in events[curdindex]: if not curdate.day in events[curdindex]:
events[curdindex][curdate.day] = [] events[curdindex][curdate.day] = []
events[curdindex][curdate.day].append(event) events[curdindex][curdate.day].append(event)
else:
break
curdate += datetime.timedelta(days=1) 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). # 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).