remove hardcoded year for calendar
This commit is contained in:
BIN
dmapp/dmweb/__init__.pyc
Normal file
BIN
dmapp/dmweb/__init__.pyc
Normal file
Binary file not shown.
@@ -1,4 +1,4 @@
|
|||||||
import datetime
|
from datetime import datetime
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
from flask import Blueprint, render_template
|
from flask import Blueprint, render_template
|
||||||
import pytz
|
import pytz
|
||||||
@@ -21,13 +21,17 @@ class DMHTMLCalendar(calendar.HTMLCalendar):
|
|||||||
def setcalmonth(self, month):
|
def setcalmonth(self, month):
|
||||||
self.dmmonth = month
|
self.dmmonth = month
|
||||||
|
|
||||||
|
def setcalyear(self, year):
|
||||||
|
self.dmyear = year
|
||||||
|
|
||||||
def oneday(self,month,day):
|
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,
|
minute=0,
|
||||||
second=0)
|
second=0)
|
||||||
|
|
||||||
end = datetime.datetime(2020, month, day).replace (hour=23,
|
end = datetime(self.dmyear, month, day).replace (hour=23,
|
||||||
minute=59,
|
minute=59,
|
||||||
second=59)
|
second=59)
|
||||||
|
|
||||||
@@ -63,11 +67,11 @@ class DMHTMLCalendar(calendar.HTMLCalendar):
|
|||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
start = datetime.datetime(2020, month, start_day).replace(hour=0,
|
start = datetime(self.dmyear, month, start_day).replace(hour=0,
|
||||||
minute=0,
|
minute=0,
|
||||||
second=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,
|
minute=59,
|
||||||
second=59)
|
second=59)
|
||||||
|
|
||||||
@@ -82,18 +86,6 @@ class DMHTMLCalendar(calendar.HTMLCalendar):
|
|||||||
return returnstr
|
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):
|
def formatweekheader(self):
|
||||||
"""
|
"""
|
||||||
Return a header for a week as a table row.
|
Return a header for a week as a table row.
|
||||||
@@ -128,13 +120,15 @@ class DMHTMLCalendar(calendar.HTMLCalendar):
|
|||||||
@dmbp.route("/calendar/<int:month>")
|
@dmbp.route("/calendar/<int:month>")
|
||||||
def calmain(month=None):
|
def calmain(month=None):
|
||||||
|
|
||||||
usemonth = datetime.datetime.today().month
|
usemonth = datetime.today().month
|
||||||
|
useyear = datetime.today().year
|
||||||
if month:
|
if month:
|
||||||
usemonth = month
|
usemonth = month
|
||||||
|
|
||||||
cal = DMHTMLCalendar(calendar.SATURDAY)
|
cal = DMHTMLCalendar(calendar.SATURDAY)
|
||||||
|
|
||||||
cal.setcalmonth(usemonth)
|
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))
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
.sat {
|
||||||
|
height: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
table {
|
table {
|
||||||
border: 1px solid black;
|
border: 1px solid black;
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,17 @@
|
|||||||
|
|
||||||
|
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
|
|
||||||
|
td > * {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
td {
|
||||||
|
vertical-align : top;
|
||||||
|
height: 25px;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
table {
|
table {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border: 1px solid black;
|
border: 1px solid black;
|
||||||
|
|||||||
@@ -15,12 +15,12 @@ switches = db.switch
|
|||||||
dailies = db.daily
|
dailies = db.daily
|
||||||
|
|
||||||
desktops = ("Work",
|
desktops = ("Work",
|
||||||
"Browse",
|
"Work",
|
||||||
"Write",
|
|
||||||
"Create",
|
"Create",
|
||||||
"Learn",
|
|
||||||
"Other",
|
"Other",
|
||||||
"Sleep")
|
"Learn",
|
||||||
|
"Challenges",
|
||||||
|
"Idle")
|
||||||
|
|
||||||
|
|
||||||
unlabeled = "Idle"
|
unlabeled = "Idle"
|
||||||
|
|||||||
Reference in New Issue
Block a user