Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 331 lines (275 sloc) 11.448 kb
2c42865 @thauber fixed file structure
thauber authored
1 import datetime
2 from django.db.models.query import QuerySet
3f35a48 @yml Add the machinery to support i18n based on a patch provided by Leidel…
yml authored
3 from django.template.defaultfilters import date
4 from django.utils.translation import ugettext, ugettext_lazy as _
92b17cc @RockHoward day names in calendars, start of week support
RockHoward authored
5 from django.utils.dates import WEEKDAYS, WEEKDAYS_ABBR
2ca6b1f @winhamwr Refactored all settings manipulation in to a schedule.conf.settings m…
winhamwr authored
6 from schedule.conf.settings import FIRST_DAY_OF_WEEK, SHOW_CANCELLED_OCCURRENCES
42fbaa0 @thauber added OccurrenceReplacer to the periods
thauber authored
7 from schedule.models import Occurrence
8 from schedule.utils import OccurrenceReplacer
456ab93 @thauber Added recurring events, lots of backwards incompatable changes. Also…
thauber authored
9
92b17cc @RockHoward day names in calendars, start of week support
RockHoward authored
10 weekday_names = []
11 weekday_abbrs = []
2ca6b1f @winhamwr Refactored all settings manipulation in to a schedule.conf.settings m…
winhamwr authored
12 if FIRST_DAY_OF_WEEK == 1:
92b17cc @RockHoward day names in calendars, start of week support
RockHoward authored
13 # The calendar week starts on Monday
14 for i in range(7):
15 weekday_names.append( WEEKDAYS[i] )
16 weekday_abbrs.append( WEEKDAYS_ABBR[i] )
17 else:
18 # The calendar week starts on Sunday, not Monday
19 weekday_names.append( WEEKDAYS[6] )
20 weekday_abbrs.append( WEEKDAYS_ABBR[6] )
21 for i in range(6):
22 weekday_names.append( WEEKDAYS[i] )
23 weekday_abbrs.append( WEEKDAYS_ABBR[i] )
24
70eee72 @bartekgorny Fixed next/prev/current API - methods return Period subclasses everyw…
bartekgorny authored
25
2c42865 @thauber fixed file structure
thauber authored
26 class Period(object):
27 '''
456ab93 @thauber Added recurring events, lots of backwards incompatable changes. Also…
thauber authored
28 This class represents a period of time. It can return a set of occurrences
603eb3e @RockHoward Added convenience functions for periods and associated tests
RockHoward authored
29 based on its events, and its time period (start and end).
2c42865 @thauber fixed file structure
thauber authored
30 '''
888d35d @thauber Working on some optimization
thauber authored
31 def __init__(self, events, start, end, parent_persisted_occurrences = None,
32 occurrence_pool=None):
2c42865 @thauber fixed file structure
thauber authored
33 self.start = start
34 self.end = end
456ab93 @thauber Added recurring events, lots of backwards incompatable changes. Also…
thauber authored
35 self.events = events
888d35d @thauber Working on some optimization
thauber authored
36 self.occurrence_pool = occurrence_pool
48b1e56 @thauber Added Year period and an optimizations thanks to Bartek Gorny
thauber authored
37 if parent_persisted_occurrences is not None:
38 self._persisted_occurrences = parent_persisted_occurrences
456ab93 @thauber Added recurring events, lots of backwards incompatable changes. Also…
thauber authored
39
2c42865 @thauber fixed file structure
thauber authored
40 def __eq__(self, period):
41 return self.start==period.start and self.end==period.end and self.events==period.events
456ab93 @thauber Added recurring events, lots of backwards incompatable changes. Also…
thauber authored
42
1855acd @bartekgorny bugfix: lack of __ne__ method caused strange results of comparisons
bartekgorny authored
43 def __ne__(self, period):
44 return self.start!=period.start or self.end!=period.end or self.events!=period.events
45
456ab93 @thauber Added recurring events, lots of backwards incompatable changes. Also…
thauber authored
46 def _get_sorted_occurrences(self):
47 occurrences = []
888d35d @thauber Working on some optimization
thauber authored
48 if hasattr(self, "occurrence_pool") and self.occurrence_pool is not None:
49 for occurrence in self.occurrence_pool:
1470059 @bartekgorny Compare occurrences to periods using gt/lt, not gte/lte
bartekgorny authored
50 if occurrence.start < self.end and occurrence.end > self.start:
888d35d @thauber Working on some optimization
thauber authored
51 occurrences.append(occurrence)
52 return occurrences
456ab93 @thauber Added recurring events, lots of backwards incompatable changes. Also…
thauber authored
53 for event in self.events:
0b52ab8 @bartekgorny Solution to the problem of missing occurrences (it also makes the log…
bartekgorny authored
54 event_occurrences = event.get_occurrences(self.start, self.end)
ff312a9 @thauber Added first try at persisted occurrences. This could is not stable, …
thauber authored
55 occurrences += event_occurrences
456ab93 @thauber Added recurring events, lots of backwards incompatable changes. Also…
thauber authored
56 return sorted(occurrences)
e12f09f @bartekgorny Optimisation part 2 - storing occurrences as "volatile attribute"
bartekgorny authored
57
58 def cached_get_sorted_occurrences(self):
59 if hasattr(self, '_occurrences'):
9e96e09 @winhamwr Fixed the TestMonth testcase. The Monday in the week of Feb 1st 2008 …
winhamwr authored
60 return self._occurrences
e12f09f @bartekgorny Optimisation part 2 - storing occurrences as "volatile attribute"
bartekgorny authored
61 occs = self._get_sorted_occurrences()
62 self._occurrences = occs
63 return occs
64 occurrences = property(cached_get_sorted_occurrences)
48b1e56 @thauber Added Year period and an optimizations thanks to Bartek Gorny
thauber authored
65
66 def get_persisted_occurrences(self):
67 if hasattr(self, '_persisted_occurrenes'):
68 return self._persisted_occurrences
69 else:
70 self._persisted_occurrences = Occurrence.objects.filter(event__in = self.events)
71 return self._persisted_occurrences
456ab93 @thauber Added recurring events, lots of backwards incompatable changes. Also…
thauber authored
72
73 def classify_occurrence(self, occurrence):
1470059 @bartekgorny Compare occurrences to periods using gt/lt, not gte/lte
bartekgorny authored
74 """
75 returns an integer marker denoting what is the relation of the
76 occurrence to the period:
77 0 - it started in the period and lasted
78 1 - it is fully contained within the period
79 2 - it lasted throughout the period
80 3 - it started before and ended within the period
81 """
2ca6b1f @winhamwr Refactored all settings manipulation in to a schedule.conf.settings m…
winhamwr authored
82 if occurrence.cancelled and not SHOW_CANCELLED_OCCURRENCES:
83 return
603eb3e @RockHoward Added convenience functions for periods and associated tests
RockHoward authored
84 if occurrence.start > self.end or occurrence.end < self.start:
85 return None
2c42865 @thauber fixed file structure
thauber authored
86 started = False
87 ended = False
73388da @yml Add a management command to laod some smaple data in the db. Add some…
yml authored
88 if occurrence.start >= self.start and occurrence.start < self.end:
2c42865 @thauber fixed file structure
thauber authored
89 started = True
73388da @yml Add a management command to laod some smaple data in the db. Add some…
yml authored
90 if occurrence.end >=self.start and occurrence.end< self.end:
2c42865 @thauber fixed file structure
thauber authored
91 ended = True
92 if started and ended:
456ab93 @thauber Added recurring events, lots of backwards incompatable changes. Also…
thauber authored
93 return {'occurrence': occurrence, 'class': 1}
2c42865 @thauber fixed file structure
thauber authored
94 elif started:
456ab93 @thauber Added recurring events, lots of backwards incompatable changes. Also…
thauber authored
95 return {'occurrence': occurrence, 'class': 0}
2c42865 @thauber fixed file structure
thauber authored
96 elif ended:
456ab93 @thauber Added recurring events, lots of backwards incompatable changes. Also…
thauber authored
97 return {'occurrence': occurrence, 'class': 3}
98 # it existed during this period but it didnt begin or end within it
2c42865 @thauber fixed file structure
thauber authored
99 # so it must have just continued
456ab93 @thauber Added recurring events, lots of backwards incompatable changes. Also…
thauber authored
100 return {'occurrence': occurrence, 'class': 2}
101
4e2c353 @thauber Fixed test and bug withPeriods.py get_sorted_occurrences, changed get…
thauber authored
102 def get_occurrence_partials(self):
456ab93 @thauber Added recurring events, lots of backwards incompatable changes. Also…
thauber authored
103 occurrence_dicts = []
104 for occurrence in self.occurrences:
105 occurrence = self.classify_occurrence(occurrence)
106 if occurrence:
107 occurrence_dicts.append(occurrence)
108 return occurrence_dicts
73388da @yml Add a management command to laod some smaple data in the db. Add some…
yml authored
109
4e2c353 @thauber Fixed test and bug withPeriods.py get_sorted_occurrences, changed get…
thauber authored
110 def get_occurrences(self):
456ab93 @thauber Added recurring events, lots of backwards incompatable changes. Also…
thauber authored
111 return self.occurrences
112
603eb3e @RockHoward Added convenience functions for periods and associated tests
RockHoward authored
113 def has_occurrences(self):
114 for occurrence in self.occurrences:
115 occurrence = self.classify_occurrence(occurrence)
116 if occurrence:
117 return True
118 return False
119
120 def get_time_slot(self, start, end ):
121 if start >= self.start and end <= self.end:
fb03f0a @bartekgorny Use occurrence pool and parent persisted occurrences when creating sl…
bartekgorny authored
122 return Period( self.events, start, end,
123 parent_persisted_occurrences=self.get_persisted_occurrences(),
124 occurrence_pool=self.occurrences)
603eb3e @RockHoward Added convenience functions for periods and associated tests
RockHoward authored
125 return None
126
70eee72 @bartekgorny Fixed next/prev/current API - methods return Period subclasses everyw…
bartekgorny authored
127 def create_sub_period(self, cls, start=None):
128 start = start or self.start
129 return cls(self.events, start, self.get_persisted_occurrences(), self.occurrences)
130
131 def get_periods(self, cls):
132 period = self.create_sub_period(cls)
133 while period.start < self.end:
134 yield self.create_sub_period(cls, period.start)
135 period = period.next()
136
137
48b1e56 @thauber Added Year period and an optimizations thanks to Bartek Gorny
thauber authored
138 class Year(Period):
139 def __init__(self, events, date=None, parent_persisted_occurrences=None):
140 if date is None:
141 date = datetime.datetime.now()
142 start, end = self._get_year_range(date)
143 super(Year, self).__init__(events, start, end, parent_persisted_occurrences)
2ca6b1f @winhamwr Refactored all settings manipulation in to a schedule.conf.settings m…
winhamwr authored
144
48b1e56 @thauber Added Year period and an optimizations thanks to Bartek Gorny
thauber authored
145 def get_months(self):
70eee72 @bartekgorny Fixed next/prev/current API - methods return Period subclasses everyw…
bartekgorny authored
146 return self.get_periods(Month)
2ca6b1f @winhamwr Refactored all settings manipulation in to a schedule.conf.settings m…
winhamwr authored
147
48b1e56 @thauber Added Year period and an optimizations thanks to Bartek Gorny
thauber authored
148 def next_year(self):
70eee72 @bartekgorny Fixed next/prev/current API - methods return Period subclasses everyw…
bartekgorny authored
149 return Year(self.events, self.end)
6fdcf9a @bartekgorny Added generic aliases to prev_*/next_* methods
bartekgorny authored
150 next = next_year
2ca6b1f @winhamwr Refactored all settings manipulation in to a schedule.conf.settings m…
winhamwr authored
151
48b1e56 @thauber Added Year period and an optimizations thanks to Bartek Gorny
thauber authored
152 def prev_year(self):
70eee72 @bartekgorny Fixed next/prev/current API - methods return Period subclasses everyw…
bartekgorny authored
153 start = datetime.datetime(self.start.year-1, self.start.month, self.start.day)
154 return Year(self.events, start)
6fdcf9a @bartekgorny Added generic aliases to prev_*/next_* methods
bartekgorny authored
155 prev = prev_year
2ca6b1f @winhamwr Refactored all settings manipulation in to a schedule.conf.settings m…
winhamwr authored
156
48b1e56 @thauber Added Year period and an optimizations thanks to Bartek Gorny
thauber authored
157 def _get_year_range(self, year):
158 start = datetime.datetime(year.year, datetime.datetime.min.month,
159 datetime.datetime.min.day)
160 end = datetime.datetime(year.year+1, datetime.datetime.min.month,
161 datetime.datetime.min.day)
162 return start, end
2ca6b1f @winhamwr Refactored all settings manipulation in to a schedule.conf.settings m…
winhamwr authored
163
48b1e56 @thauber Added Year period and an optimizations thanks to Bartek Gorny
thauber authored
164 def __unicode__(self):
165 return self.start.strftime('%Y')
2ca6b1f @winhamwr Refactored all settings manipulation in to a schedule.conf.settings m…
winhamwr authored
166
167
603eb3e @RockHoward Added convenience functions for periods and associated tests
RockHoward authored
168
2c42865 @thauber fixed file structure
thauber authored
169 class Month(Period):
170 """
171 The month period has functions for retrieving the week periods within this period
172 and day periods within the date.
173 """
888d35d @thauber Working on some optimization
thauber authored
174 def __init__(self, events, date=None, parent_persisted_occurrences=None,
175 occurrence_pool=None):
8d19da4 @thauber * Added the start to the documentation.
thauber authored
176 if date is None:
177 date = datetime.datetime.now()
4a33d2c @thauber fixed small bugs
thauber authored
178 start, end = self._get_month_range(date)
2ca6b1f @winhamwr Refactored all settings manipulation in to a schedule.conf.settings m…
winhamwr authored
179 super(Month, self).__init__(events, start, end,
888d35d @thauber Working on some optimization
thauber authored
180 parent_persisted_occurrences, occurrence_pool)
456ab93 @thauber Added recurring events, lots of backwards incompatable changes. Also…
thauber authored
181
2c42865 @thauber fixed file structure
thauber authored
182 def get_weeks(self):
70eee72 @bartekgorny Fixed next/prev/current API - methods return Period subclasses everyw…
bartekgorny authored
183 return self.get_periods(Week)
184 date = self.star
456ab93 @thauber Added recurring events, lots of backwards incompatable changes. Also…
thauber authored
185
2c42865 @thauber fixed file structure
thauber authored
186 def get_days(self):
70eee72 @bartekgorny Fixed next/prev/current API - methods return Period subclasses everyw…
bartekgorny authored
187 return self.get_periods(Day)
456ab93 @thauber Added recurring events, lots of backwards incompatable changes. Also…
thauber authored
188
6539d7e @RockHoward many new views and templates
RockHoward authored
189 def get_day(self, daynumber ):
190 date = self.start
191 if daynumber > 1:
192 date += datetime.timedelta(days=daynumber-1)
70eee72 @bartekgorny Fixed next/prev/current API - methods return Period subclasses everyw…
bartekgorny authored
193 return self.create_sub_period(Day, date)
456ab93 @thauber Added recurring events, lots of backwards incompatable changes. Also…
thauber authored
194
2c42865 @thauber fixed file structure
thauber authored
195 def next_month(self):
70eee72 @bartekgorny Fixed next/prev/current API - methods return Period subclasses everyw…
bartekgorny authored
196 return Month(self.events, self.end)
6fdcf9a @bartekgorny Added generic aliases to prev_*/next_* methods
bartekgorny authored
197 next = next_month
2ca6b1f @winhamwr Refactored all settings manipulation in to a schedule.conf.settings m…
winhamwr authored
198
dd29dfb @thauber added the ability to move through months in the template: sending all…
thauber authored
199 def prev_month(self):
70eee72 @bartekgorny Fixed next/prev/current API - methods return Period subclasses everyw…
bartekgorny authored
200 start = (self.start - datetime.timedelta(days=1)).replace(day=1)
201 return Month(self.events, start)
6fdcf9a @bartekgorny Added generic aliases to prev_*/next_* methods
bartekgorny authored
202 prev = prev_month
603eb3e @RockHoward Added convenience functions for periods and associated tests
RockHoward authored
203
204 def current_year(self):
70eee72 @bartekgorny Fixed next/prev/current API - methods return Period subclasses everyw…
bartekgorny authored
205 return Year(self.events, self.start)
603eb3e @RockHoward Added convenience functions for periods and associated tests
RockHoward authored
206
207 def prev_year(self):
70eee72 @bartekgorny Fixed next/prev/current API - methods return Period subclasses everyw…
bartekgorny authored
208 start = datetime.datetime.min.replace(year=self.start.year-1)
209 return Year(self.events, start)
603eb3e @RockHoward Added convenience functions for periods and associated tests
RockHoward authored
210
211 def next_year(self):
70eee72 @bartekgorny Fixed next/prev/current API - methods return Period subclasses everyw…
bartekgorny authored
212 start = datetime.datetime.min.replace(year=self.start.year+1)
213 return Year(self.events, start)
456ab93 @thauber Added recurring events, lots of backwards incompatable changes. Also…
thauber authored
214
4a33d2c @thauber fixed small bugs
thauber authored
215 def _get_month_range(self, month):
48b1e56 @thauber Added Year period and an optimizations thanks to Bartek Gorny
thauber authored
216 year = month.year
217 month = month.month
218 start = datetime.datetime.min.replace(year=year, month=month)
219 if month == 12:
220 end = start.replace(month=1, year=year+1)
2c42865 @thauber fixed file structure
thauber authored
221 else:
48b1e56 @thauber Added Year period and an optimizations thanks to Bartek Gorny
thauber authored
222 end = start.replace(month=month+1)
2c42865 @thauber fixed file structure
thauber authored
223 return start, end
456ab93 @thauber Added recurring events, lots of backwards incompatable changes. Also…
thauber authored
224
3f35a48 @yml Add the machinery to support i18n based on a patch provided by Leidel…
yml authored
225 def __unicode__(self):
48b1e56 @thauber Added Year period and an optimizations thanks to Bartek Gorny
thauber authored
226 return self.name()
456ab93 @thauber Added recurring events, lots of backwards incompatable changes. Also…
thauber authored
227
2c42865 @thauber fixed file structure
thauber authored
228 def name(self):
229 return self.start.strftime('%B')
456ab93 @thauber Added recurring events, lots of backwards incompatable changes. Also…
thauber authored
230
2c42865 @thauber fixed file structure
thauber authored
231 def year(self):
232 return self.start.strftime('%Y')
233
70eee72 @bartekgorny Fixed next/prev/current API - methods return Period subclasses everyw…
bartekgorny authored
234
2c42865 @thauber fixed file structure
thauber authored
235 class Week(Period):
236 """
237 The Week period that has functions for retrieving Day periods within it
238 """
2ca6b1f @winhamwr Refactored all settings manipulation in to a schedule.conf.settings m…
winhamwr authored
239 def __init__(self, events, date=None, parent_persisted_occurrences=None,
888d35d @thauber Working on some optimization
thauber authored
240 occurrence_pool=None):
8d19da4 @thauber * Added the start to the documentation.
thauber authored
241 if date is None:
242 date = datetime.datetime.now()
2c42865 @thauber fixed file structure
thauber authored
243 start, end = self._get_week_range(date)
2ca6b1f @winhamwr Refactored all settings manipulation in to a schedule.conf.settings m…
winhamwr authored
244 super(Week, self).__init__(events, start, end,
888d35d @thauber Working on some optimization
thauber authored
245 parent_persisted_occurrences, occurrence_pool)
2ca6b1f @winhamwr Refactored all settings manipulation in to a schedule.conf.settings m…
winhamwr authored
246
ba22847 @bartekgorny added prev/next methods to Week
bartekgorny authored
247 def prev_week(self):
70eee72 @bartekgorny Fixed next/prev/current API - methods return Period subclasses everyw…
bartekgorny authored
248 return Week(self.events, self.start - datetime.timedelta(days=7))
ba22847 @bartekgorny added prev/next methods to Week
bartekgorny authored
249 prev = prev_week
250
2c42865 @thauber fixed file structure
thauber authored
251 def next_week(self):
70eee72 @bartekgorny Fixed next/prev/current API - methods return Period subclasses everyw…
bartekgorny authored
252 return Week(self.events, self.end)
ba22847 @bartekgorny added prev/next methods to Week
bartekgorny authored
253 next = next_week
456ab93 @thauber Added recurring events, lots of backwards incompatable changes. Also…
thauber authored
254
70eee72 @bartekgorny Fixed next/prev/current API - methods return Period subclasses everyw…
bartekgorny authored
255 def current_month(self):
256 return Month(self.events, self.start)
257
258 def current_year(self):
259 return Year(self.events, self.start)
260
2c42865 @thauber fixed file structure
thauber authored
261 def get_days(self):
70eee72 @bartekgorny Fixed next/prev/current API - methods return Period subclasses everyw…
bartekgorny authored
262 return self.get_periods(Day)
456ab93 @thauber Added recurring events, lots of backwards incompatable changes. Also…
thauber authored
263
2c42865 @thauber fixed file structure
thauber authored
264 def _get_week_range(self, week):
265 if isinstance(week, datetime.datetime):
266 week = week.date()
92b17cc @RockHoward day names in calendars, start of week support
RockHoward authored
267 # Adjust the start datetime to midnight of the week datetime
2c42865 @thauber fixed file structure
thauber authored
268 start = datetime.datetime.combine(week, datetime.time.min)
92b17cc @RockHoward day names in calendars, start of week support
RockHoward authored
269 # Adjust the start datetime to Monday or Sunday of the current week
270 sub_days = 0
2ca6b1f @winhamwr Refactored all settings manipulation in to a schedule.conf.settings m…
winhamwr authored
271 if FIRST_DAY_OF_WEEK == 1:
92b17cc @RockHoward day names in calendars, start of week support
RockHoward authored
272 # The week begins on Monday
273 sub_days = start.isoweekday() - 1
274 else:
275 # The week begins on Sunday
276 sub_days = start.isoweekday()
277 if sub_days == 7:
278 sub_days = 0
279 if sub_days > 0:
280 start = start - datetime.timedelta(days=sub_days)
2c42865 @thauber fixed file structure
thauber authored
281 end = start + datetime.timedelta(days=7)
282 return start, end
456ab93 @thauber Added recurring events, lots of backwards incompatable changes. Also…
thauber authored
283
3f35a48 @yml Add the machinery to support i18n based on a patch provided by Leidel…
yml authored
284 def __unicode__(self):
285 date_format = u'l, %s' % ugettext("DATE_FORMAT")
286 return ugettext('Week: %(start)s-%(end)s') % {
287 'start': date(self.start, date_format),
288 'end': date(self.end, date_format),
289 }
2c42865 @thauber fixed file structure
thauber authored
290
70eee72 @bartekgorny Fixed next/prev/current API - methods return Period subclasses everyw…
bartekgorny authored
291
2c42865 @thauber fixed file structure
thauber authored
292 class Day(Period):
888d35d @thauber Working on some optimization
thauber authored
293 def __init__(self, events, date=None, parent_persisted_occurrences=None,
294 occurrence_pool=None):
8d19da4 @thauber * Added the start to the documentation.
thauber authored
295 if date is None:
296 date = datetime.datetime.now()
48b1e56 @thauber Added Year period and an optimizations thanks to Bartek Gorny
thauber authored
297 start, end = self._get_day_range(date)
2ca6b1f @winhamwr Refactored all settings manipulation in to a schedule.conf.settings m…
winhamwr authored
298 super(Day, self).__init__(events, start, end,
888d35d @thauber Working on some optimization
thauber authored
299 parent_persisted_occurrences, occurrence_pool)
48b1e56 @thauber Added Year period and an optimizations thanks to Bartek Gorny
thauber authored
300
301 def _get_day_range(self, date):
2c42865 @thauber fixed file structure
thauber authored
302 if isinstance(date, datetime.datetime):
303 date = date.date()
48b1e56 @thauber Added Year period and an optimizations thanks to Bartek Gorny
thauber authored
304 start = datetime.datetime.combine(date, datetime.time.min)
305 end = start + datetime.timedelta(days=1)
306 return start, end
456ab93 @thauber Added recurring events, lots of backwards incompatable changes. Also…
thauber authored
307
3f35a48 @yml Add the machinery to support i18n based on a patch provided by Leidel…
yml authored
308 def __unicode__(self):
309 date_format = u'l, %s' % ugettext("DATE_FORMAT")
310 return ugettext('Day: %(start)s-%(end)s') % {
311 'start': date(self.start, date_format),
312 'end': date(self.end, date_format),
313 }
456ab93 @thauber Added recurring events, lots of backwards incompatable changes. Also…
thauber authored
314
603eb3e @RockHoward Added convenience functions for periods and associated tests
RockHoward authored
315 def prev_day(self):
70eee72 @bartekgorny Fixed next/prev/current API - methods return Period subclasses everyw…
bartekgorny authored
316 return Day(self.events, self.start - datetime.timedelta(days=1))
6fdcf9a @bartekgorny Added generic aliases to prev_*/next_* methods
bartekgorny authored
317 prev = prev_day
603eb3e @RockHoward Added convenience functions for periods and associated tests
RockHoward authored
318
2c42865 @thauber fixed file structure
thauber authored
319 def next_day(self):
70eee72 @bartekgorny Fixed next/prev/current API - methods return Period subclasses everyw…
bartekgorny authored
320 return Day(self.events, self.end)
6fdcf9a @bartekgorny Added generic aliases to prev_*/next_* methods
bartekgorny authored
321 next = next_day
456ab93 @thauber Added recurring events, lots of backwards incompatable changes. Also…
thauber authored
322
70eee72 @bartekgorny Fixed next/prev/current API - methods return Period subclasses everyw…
bartekgorny authored
323 def current_year(self):
324 return Year(self.events, self.start)
325
326 def current_month(self):
2c42865 @thauber fixed file structure
thauber authored
327 return Month(self.events, self.start)
456ab93 @thauber Added recurring events, lots of backwards incompatable changes. Also…
thauber authored
328
70eee72 @bartekgorny Fixed next/prev/current API - methods return Period subclasses everyw…
bartekgorny authored
329 def current_week(self):
2c42865 @thauber fixed file structure
thauber authored
330 return Week(self.events, self.start)
Something went wrong with that request. Please try again.