Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes | Properties
calendar.LocaleHTMLCalendar Class Reference
Inheritance diagram for calendar.LocaleHTMLCalendar:
Inheritance graph
[legend]
Collaboration diagram for calendar.LocaleHTMLCalendar:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def formatweekday
def formatmonthname
def formatday
def formatweek
def formatweekheader
def formatmonth
def formatyear
def formatyearpage
def getfirstweekday
def setfirstweekday
def iterweekdays
def itermonthdates
def itermonthdays2
def itermonthdays
def monthdatescalendar
def monthdays2calendar
def monthdayscalendar
def yeardatescalendar
def yeardays2calendar
def yeardayscalendar

Public Attributes

 locale
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Static Public Attributes

list cssclasses = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"]

Properties

 firstweekday = property(getfirstweekday, setfirstweekday)

Detailed Description

This class can be passed a locale name in the constructor and will return
month and weekday names in the specified locale. If this locale includes
an encoding all strings containing month and weekday names will be returned
as unicode.

Definition at line 527 of file calendar.py.


Constructor & Destructor Documentation

def calendar.LocaleHTMLCalendar.__init__ (   self,
  firstweekday = 0,
  locale = None 
)

Definition at line 534 of file calendar.py.

00534 
00535     def __init__(self, firstweekday=0, locale=None):
00536         HTMLCalendar.__init__(self, firstweekday)
00537         if locale is None:
00538             locale = _locale.getdefaultlocale()
00539         self.locale = locale

Here is the caller graph for this function:


Member Function Documentation

def calendar.HTMLCalendar.formatday (   self,
  day,
  weekday 
) [inherited]
Return a day as a table cell.

Definition at line 380 of file calendar.py.

00380 
00381     def formatday(self, day, weekday):
00382         """
00383         Return a day as a table cell.
00384         """
00385         if day == 0:
00386             return '<td class="noday">&nbsp;</td>' # day outside month
00387         else:
00388             return '<td class="%s">%d</td>' % (self.cssclasses[weekday], day)

Here is the caller graph for this function:

def calendar.HTMLCalendar.formatmonth (   self,
  theyear,
  themonth,
  withyear = True 
) [inherited]
Return a formatted month as a table.

Definition at line 419 of file calendar.py.

00419 
00420     def formatmonth(self, theyear, themonth, withyear=True):
00421         """
00422         Return a formatted month as a table.
00423         """
00424         v = []
00425         a = v.append
00426         a('<table border="0" cellpadding="0" cellspacing="0" class="month">')
00427         a('\n')
00428         a(self.formatmonthname(theyear, themonth, withyear=withyear))
00429         a('\n')
00430         a(self.formatweekheader())
00431         a('\n')
00432         for week in self.monthdays2calendar(theyear, themonth):
00433             a(self.formatweek(week))
00434             a('\n')
00435         a('</table>')
00436         a('\n')
00437         return ''.join(v)

Here is the call graph for this function:

Here is the caller graph for this function:

def calendar.LocaleHTMLCalendar.formatmonthname (   self,
  theyear,
  themonth,
  withyear = True 
)
Return a month name as a table row.

Reimplemented from calendar.HTMLCalendar.

Definition at line 545 of file calendar.py.

00545 
00546     def formatmonthname(self, theyear, themonth, withyear=True):
00547         with different_locale(self.locale):
00548             s = month_name[themonth]
00549             if withyear:
00550                 s = '%s %s' % (s, theyear)
00551             return '<tr><th colspan="7" class="month">%s</th></tr>' % s
00552 
00553 
# Support for old module level interface
def calendar.HTMLCalendar.formatweek (   self,
  theweek 
) [inherited]
Return a complete week as a table row.

Definition at line 389 of file calendar.py.

00389 
00390     def formatweek(self, theweek):
00391         """
00392         Return a complete week as a table row.
00393         """
00394         s = ''.join(self.formatday(d, wd) for (d, wd) in theweek)
00395         return '<tr>%s</tr>' % s

Here is the call graph for this function:

Here is the caller graph for this function:

def calendar.LocaleHTMLCalendar.formatweekday (   self,
  day 
)
Return a weekday name as a table header.

Reimplemented from calendar.HTMLCalendar.

Definition at line 540 of file calendar.py.

00540 
00541     def formatweekday(self, day):
00542         with different_locale(self.locale):
00543             s = day_abbr[day]
00544             return '<th class="%s">%s</th>' % (self.cssclasses[day], s)

def calendar.HTMLCalendar.formatweekheader (   self) [inherited]
Return a header for a week as a table row.

Definition at line 402 of file calendar.py.

00402 
00403     def formatweekheader(self):
00404         """
00405         Return a header for a week as a table row.
00406         """
00407         s = ''.join(self.formatweekday(i) for i in self.iterweekdays())
00408         return '<tr>%s</tr>' % s

Here is the call graph for this function:

Here is the caller graph for this function:

def calendar.HTMLCalendar.formatyear (   self,
  theyear,
  width = 3 
) [inherited]
Return a formatted year as a table of tables.

Definition at line 438 of file calendar.py.

00438 
00439     def formatyear(self, theyear, width=3):
00440         """
00441         Return a formatted year as a table of tables.
00442         """
00443         v = []
00444         a = v.append
00445         width = max(width, 1)
00446         a('<table border="0" cellpadding="0" cellspacing="0" class="year">')
00447         a('\n')
00448         a('<tr><th colspan="%d" class="year">%s</th></tr>' % (width, theyear))
00449         for i in range(January, January+12, width):
00450             # months in this row
00451             months = range(i, min(i+width, 13))
00452             a('<tr>')
00453             for m in months:
00454                 a('<td>')
00455                 a(self.formatmonth(theyear, m, withyear=False))
00456                 a('</td>')
00457             a('</tr>')
00458         a('</table>')
00459         return ''.join(v)

Here is the call graph for this function:

Here is the caller graph for this function:

def calendar.HTMLCalendar.formatyearpage (   self,
  theyear,
  width = 3,
  css = 'calendar.css',
  encoding = None 
) [inherited]
Return a formatted year as a complete HTML page.

Definition at line 460 of file calendar.py.

00460 
00461     def formatyearpage(self, theyear, width=3, css='calendar.css', encoding=None):
00462         """
00463         Return a formatted year as a complete HTML page.
00464         """
00465         if encoding is None:
00466             encoding = sys.getdefaultencoding()
00467         v = []
00468         a = v.append
00469         a('<?xml version="1.0" encoding="%s"?>\n' % encoding)
00470         a('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n')
00471         a('<html>\n')
00472         a('<head>\n')
00473         a('<meta http-equiv="Content-Type" content="text/html; charset=%s" />\n' % encoding)
00474         if css is not None:
00475             a('<link rel="stylesheet" type="text/css" href="%s" />\n' % css)
00476         a('<title>Calendar for %d</title>\n' % theyear)
00477         a('</head>\n')
00478         a('<body>\n')
00479         a(self.formatyear(theyear, width))
00480         a('</body>\n')
00481         a('</html>\n')
00482         return ''.join(v).encode(encoding, "xmlcharrefreplace")
00483 

Here is the call graph for this function:

def calendar.Calendar.getfirstweekday (   self) [inherited]

Definition at line 135 of file calendar.py.

00135 
00136     def getfirstweekday(self):
00137         return self._firstweekday % 7

def calendar.Calendar.itermonthdates (   self,
  year,
  month 
) [inherited]
Return an iterator for one month. The iterator will yield datetime.date
values and will always iterate through complete weeks, so it will yield
dates outside the specified month.

Definition at line 151 of file calendar.py.

00151 
00152     def itermonthdates(self, year, month):
00153         """
00154         Return an iterator for one month. The iterator will yield datetime.date
00155         values and will always iterate through complete weeks, so it will yield
00156         dates outside the specified month.
00157         """
00158         date = datetime.date(year, month, 1)
00159         # Go back to the beginning of the week
00160         days = (date.weekday() - self.firstweekday) % 7
00161         date -= datetime.timedelta(days=days)
00162         oneday = datetime.timedelta(days=1)
00163         while True:
00164             yield date
00165             date += oneday
00166             if date.month != month and date.weekday() == self.firstweekday:
00167                 break

Here is the caller graph for this function:

def calendar.Calendar.itermonthdays (   self,
  year,
  month 
) [inherited]
Like itermonthdates(), but will yield day numbers. For days outside
the specified month the day number is 0.

Definition at line 179 of file calendar.py.

00179 
00180     def itermonthdays(self, year, month):
00181         """
00182         Like itermonthdates(), but will yield day numbers. For days outside
00183         the specified month the day number is 0.
00184         """
00185         for date in self.itermonthdates(year, month):
00186             if date.month != month:
00187                 yield 0
00188             else:
00189                 yield date.day

Here is the call graph for this function:

Here is the caller graph for this function:

def calendar.Calendar.itermonthdays2 (   self,
  year,
  month 
) [inherited]
Like itermonthdates(), but will yield (day number, weekday number)
tuples. For days outside the specified month the day number is 0.

Definition at line 168 of file calendar.py.

00168 
00169     def itermonthdays2(self, year, month):
00170         """
00171         Like itermonthdates(), but will yield (day number, weekday number)
00172         tuples. For days outside the specified month the day number is 0.
00173         """
00174         for date in self.itermonthdates(year, month):
00175             if date.month != month:
00176                 yield (0, date.weekday())
00177             else:
00178                 yield (date.day, date.weekday())

Here is the call graph for this function:

Here is the caller graph for this function:

def calendar.Calendar.iterweekdays (   self) [inherited]
Return a iterator for one week of weekday numbers starting with the
configured first one.

Definition at line 143 of file calendar.py.

00143 
00144     def iterweekdays(self):
00145         """
00146         Return a iterator for one week of weekday numbers starting with the
00147         configured first one.
00148         """
00149         for i in range(self.firstweekday, self.firstweekday + 7):
00150             yield i%7

Here is the caller graph for this function:

def calendar.Calendar.monthdatescalendar (   self,
  year,
  month 
) [inherited]
Return a matrix (list of lists) representing a month's calendar.
Each row represents a week; week entries are datetime.date values.

Definition at line 190 of file calendar.py.

00190 
00191     def monthdatescalendar(self, year, month):
00192         """
00193         Return a matrix (list of lists) representing a month's calendar.
00194         Each row represents a week; week entries are datetime.date values.
00195         """
00196         dates = list(self.itermonthdates(year, month))
00197         return [ dates[i:i+7] for i in range(0, len(dates), 7) ]

Here is the call graph for this function:

Here is the caller graph for this function:

def calendar.Calendar.monthdays2calendar (   self,
  year,
  month 
) [inherited]
Return a matrix representing a month's calendar.
Each row represents a week; week entries are
(day number, weekday number) tuples. Day numbers outside this month
are zero.

Definition at line 198 of file calendar.py.

00198 
00199     def monthdays2calendar(self, year, month):
00200         """
00201         Return a matrix representing a month's calendar.
00202         Each row represents a week; week entries are
00203         (day number, weekday number) tuples. Day numbers outside this month
00204         are zero.
00205         """
00206         days = list(self.itermonthdays2(year, month))
00207         return [ days[i:i+7] for i in range(0, len(days), 7) ]

Here is the call graph for this function:

Here is the caller graph for this function:

def calendar.Calendar.monthdayscalendar (   self,
  year,
  month 
) [inherited]
Return a matrix representing a month's calendar.
Each row represents a week; days outside this month are zero.

Definition at line 208 of file calendar.py.

00208 
00209     def monthdayscalendar(self, year, month):
00210         """
00211         Return a matrix representing a month's calendar.
00212         Each row represents a week; days outside this month are zero.
00213         """
00214         days = list(self.itermonthdays(year, month))
00215         return [ days[i:i+7] for i in range(0, len(days), 7) ]

Here is the call graph for this function:

Here is the caller graph for this function:

def calendar.Calendar.setfirstweekday (   self,
  firstweekday 
) [inherited]

Definition at line 138 of file calendar.py.

00138 
00139     def setfirstweekday(self, firstweekday):
00140         self._firstweekday = firstweekday

def calendar.Calendar.yeardatescalendar (   self,
  year,
  width = 3 
) [inherited]
Return the data for the specified year ready for formatting. The return
value is a list of month rows. Each month row contains upto width months.
Each month contains between 4 and 6 weeks and each week contains 1-7
days. Days are datetime.date objects.

Definition at line 216 of file calendar.py.

00216 
00217     def yeardatescalendar(self, year, width=3):
00218         """
00219         Return the data for the specified year ready for formatting. The return
00220         value is a list of month rows. Each month row contains upto width months.
00221         Each month contains between 4 and 6 weeks and each week contains 1-7
00222         days. Days are datetime.date objects.
00223         """
00224         months = [
00225             self.monthdatescalendar(year, i)
00226             for i in range(January, January+12)
00227         ]
00228         return [months[i:i+width] for i in range(0, len(months), width) ]

Here is the call graph for this function:

def calendar.Calendar.yeardays2calendar (   self,
  year,
  width = 3 
) [inherited]
Return the data for the specified year ready for formatting (similar to
yeardatescalendar()). Entries in the week lists are
(day number, weekday number) tuples. Day numbers outside this month are
zero.

Definition at line 229 of file calendar.py.

00229 
00230     def yeardays2calendar(self, year, width=3):
00231         """
00232         Return the data for the specified year ready for formatting (similar to
00233         yeardatescalendar()). Entries in the week lists are
00234         (day number, weekday number) tuples. Day numbers outside this month are
00235         zero.
00236         """
00237         months = [
00238             self.monthdays2calendar(year, i)
00239             for i in range(January, January+12)
00240         ]
00241         return [months[i:i+width] for i in range(0, len(months), width) ]

Here is the call graph for this function:

Here is the caller graph for this function:

def calendar.Calendar.yeardayscalendar (   self,
  year,
  width = 3 
) [inherited]
Return the data for the specified year ready for formatting (similar to
yeardatescalendar()). Entries in the week lists are day numbers.
Day numbers outside this month are zero.

Definition at line 242 of file calendar.py.

00242 
00243     def yeardayscalendar(self, year, width=3):
00244         """
00245         Return the data for the specified year ready for formatting (similar to
00246         yeardatescalendar()). Entries in the week lists are day numbers.
00247         Day numbers outside this month are zero.
00248         """
00249         months = [
00250             self.monthdayscalendar(year, i)
00251             for i in range(January, January+12)
00252         ]
00253         return [months[i:i+width] for i in range(0, len(months), width) ]
00254 

Here is the call graph for this function:


Member Data Documentation

list calendar.HTMLCalendar.cssclasses = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"] [static, inherited]

Definition at line 378 of file calendar.py.

Definition at line 538 of file calendar.py.

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.


Property Documentation

Definition at line 141 of file calendar.py.


The documentation for this class was generated from the following file: