From 7a8367893cafddccbc9858ebdb56d9752b95bfd8 Mon Sep 17 00:00:00 2001 From: Mariano Ramon Date: Sun, 23 Jan 2022 18:16:58 -0300 Subject: [PATCH] remove hardcoded year for calendar --- dmapp/dmweb/__init__.pyc | Bin 0 -> 533 bytes dmapp/dmweb/dmcal.py | 34 ++++++++++++---------------- dmapp/dmweb/static/styles/dm.css | 4 ++++ dmapp/dmweb/templates/calendar.html | 11 +++++++++ dmmain.py | 8 +++---- notes.md | 1 + 6 files changed, 34 insertions(+), 24 deletions(-) create mode 100644 dmapp/dmweb/__init__.pyc create mode 100644 notes.md diff --git a/dmapp/dmweb/__init__.pyc b/dmapp/dmweb/__init__.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ed385b7ceaf6004226102afc070346e49a085957 GIT binary patch literal 533 zcmbtQy-ve05dQ3>h*ls~3_L?v$N(ckNJxwwQl<=8No|VTxQ%Q_2ni+_cpDy$2Y@>l z!2@9VKHvX+zU=dGBHlml7Wg@m-Yb%DMxf~mbbu461q9m?orKF!XK*>{oV*#{fO-U- zV_uA?&VJD;1Zk1Yo307#f;&eB?UGl!Mbo9ZoXCM|l5j#0)7)2q7t#fu0VNq%8Dfsr z2ow@z&r{P`98--pVeL#bzStwHBH>)%)(>Vk&$Pob9+AtNr45v++HNqtx0_fcuAHu2 z+wYiXWHo(X(1QfwoV4;`>rCkyZ=21wblUpzcXFv66%am}wp7Y)Y*gyBe~J?-TzJz& zqbPyLgna_Y134B`IZKoi$$MVajy!KJwMyhFUQop!{Uh{GR!rf-ZS~NZOa6agVpDM} FzX6EbZD0TZ literal 0 HcmV?d00001 diff --git a/dmapp/dmweb/dmcal.py b/dmapp/dmweb/dmcal.py index 0de9875..866af14 100644 --- a/dmapp/dmweb/dmcal.py +++ b/dmapp/dmweb/dmcal.py @@ -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 '%s' % ( - # 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/") 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)) diff --git a/dmapp/dmweb/static/styles/dm.css b/dmapp/dmweb/static/styles/dm.css index ee20e41..14dc11a 100644 --- a/dmapp/dmweb/static/styles/dm.css +++ b/dmapp/dmweb/static/styles/dm.css @@ -1,3 +1,7 @@ +.sat { + height: 200px; +} + table { border: 1px solid black; } \ No newline at end of file diff --git a/dmapp/dmweb/templates/calendar.html b/dmapp/dmweb/templates/calendar.html index 6603aea..5f85e93 100644 --- a/dmapp/dmweb/templates/calendar.html +++ b/dmapp/dmweb/templates/calendar.html @@ -4,6 +4,17 @@