remove hardcoded year for calendar

This commit is contained in:
Mariano Ramon
2022-01-23 18:16:58 -03:00
parent 59964dcab3
commit 7a8367893c
6 changed files with 34 additions and 24 deletions

BIN
dmapp/dmweb/__init__.pyc Normal file

Binary file not shown.

View File

@@ -1,4 +1,4 @@
import datetime
from datetime import datetime
from pprint import pprint
from flask import Blueprint, render_template
import pytz
@@ -21,13 +21,17 @@ class DMHTMLCalendar(calendar.HTMLCalendar):
def setcalmonth(self, month):
self.dmmonth = month
def setcalyear(self, year):
self.dmyear = year
def oneday(self,month,day):
start = datetime.datetime(2020, month, day).replace(hour=0,
current_year = datetime.today().year
start = datetime(self.dmyear, month, day).replace(hour=0,
minute=0,
second=0)
end = datetime.datetime(2020, month, day).replace (hour=23,
end = datetime(self.dmyear, month, day).replace (hour=23,
minute=59,
second=59)
@@ -63,11 +67,11 @@ class DMHTMLCalendar(calendar.HTMLCalendar):
break
start = datetime.datetime(2020, month, start_day).replace(hour=0,
start = datetime(self.dmyear, month, start_day).replace(hour=0,
minute=0,
second=0)
end = datetime.datetime(2020, month, end_day).replace (hour=23,
end = datetime(self.dmyear, month, end_day).replace (hour=23,
minute=59,
second=59)
@@ -82,18 +86,6 @@ class DMHTMLCalendar(calendar.HTMLCalendar):
return returnstr
# def formatmonthname(self, theyear, themonth, withyear=True):
# """
# Return a month name as a table row.
# """
# if withyear:
# s = '%s %s' % (month_name[themonth], theyear)
# else:
# s = '%s' % month_name[themonth]
# return '<tr><th colspan="8" class="%s">%s</th></tr>' % (
# self.cssclass_month_head, s)
def formatweekheader(self):
"""
Return a header for a week as a table row.
@@ -128,13 +120,15 @@ class DMHTMLCalendar(calendar.HTMLCalendar):
@dmbp.route("/calendar/<int:month>")
def calmain(month=None):
usemonth = datetime.datetime.today().month
usemonth = datetime.today().month
useyear = datetime.today().year
if month:
usemonth = month
cal = DMHTMLCalendar(calendar.SATURDAY)
cal.setcalmonth(usemonth)
cal.setcalyear(useyear)
return render_template("calendar.html", content=cal.formatmonth(2020,usemonth))
return render_template("calendar.html", content=cal.formatmonth(useyear,usemonth))

View File

@@ -1,3 +1,7 @@
.sat {
height: 200px;
}
table {
border: 1px solid black;
}

View File

@@ -4,6 +4,17 @@
<style type="text/css">
td > * {
}
td {
vertical-align : top;
height: 25px;
}
table {
width: 100%;
border: 1px solid black;

View File

@@ -15,12 +15,12 @@ switches = db.switch
dailies = db.daily
desktops = ("Work",
"Browse",
"Write",
"Work",
"Create",
"Learn",
"Other",
"Sleep")
"Learn",
"Challenges",
"Idle")
unlabeled = "Idle"

1
notes.md Normal file
View File

@@ -0,0 +1 @@
check weird thing of not showing the desktop where you start the dmmain script unless you move the window around