Back to index

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

List of all members.

Public Member Functions

def __init__
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

_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Properties

 firstweekday = property(getfirstweekday, setfirstweekday)

Private Attributes

 _firstweekday

Detailed Description

Base calendar class. This class doesn't do any formatting. It simply
provides data to subclasses.

Definition at line 126 of file calendar.py.


Constructor & Destructor Documentation

def calendar.Calendar.__init__ (   self,
  firstweekday = 0 
)

Definition at line 132 of file calendar.py.

00132 
00133     def __init__(self, firstweekday=0):
00134         self.firstweekday = firstweekday # 0 = Monday, 6 = Sunday

Here is the caller graph for this function:


Member Function Documentation

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 
)
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 
)
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 
)
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:

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 
)
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 
)
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 
)
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 
)

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 
)
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 
)
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 
)
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

Definition at line 139 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: