Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit b75c9ebc2d1a37222fce01592660d1a9d5636983
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue Nov 6 08:27:05 2012 +0100
Overload the formatday method to allow giving a specific class to the current day
>---------------------------------------------------------------
fedocal/fedocallib/fedora_calendar.py | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/fedocal/fedocallib/fedora_calendar.py b/fedocal/fedocallib/fedora_calendar.py
index 093a7ba..43c1807 100644
--- a/fedocal/fedocallib/fedora_calendar.py
+++ b/fedocal/fedocallib/fedora_calendar.py
@@ -14,13 +14,30 @@ See http://www.gnu.org/copyleft/gpl.html for the full text of the
license.
"""
+from datetime import date
from calendar import HTMLCalendar
+
class FedocalCalendar(HTMLCalendar):
""" Improve Python's HTMLCalendar object adding
html validation and some features 'locally required'
"""
+ def formatday(self, day, weekday):
+ """
+ Return a day as a table cell.
+ """
+ cur_date = date.today()
+ if day == 0:
+ return '<td class="noday"> </td>' # day outside month
+ else:
+ if day == cur_date.day:
+ return '<td class="%s, today">%d</td>' % (
+ self.cssclasses[weekday], day)
+ else:
+ return '<td class="%s">%d</td>' % (
+ self.cssclasses[weekday], day)
+
def formatmonth(self, theyear, themonth, withyear=True):
"""
Return a formatted month as a html valid table.