Skip to content

Commit 74f98e0

Browse files
committed
Merge pull request #2 from bijancn/master
moved all_day out of RRULE
2 parents 5b66dfb + fda40d1 commit 74f98e0

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

Diff for: calendar_parser.py

+13-8
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,15 @@ def _multi_replace(string, replace_dict):
6464
string = string.replace(str(key), str(value))
6565
return string
6666

67+
def to_unicode_or_bust(obj, encoding='utf-8'):
68+
if isinstance(obj, basestring):
69+
if not isinstance(obj, unicode):
70+
obj = unicode(obj, encoding)
71+
return obj
72+
6773
def _normalize(data_string, convert_whitespace=False):
6874
"Removes various markup artifacts and returns a normal python string."
69-
new_string = unescape(str(data_string))
75+
new_string = unescape(to_unicode_or_bust(data_string))
7076
new_string = _multi_replace(new_string, {
7177
' ': ' ', '"': '"', '¦': '|', "'": "'", "\\": ""
7278
})
@@ -343,6 +349,12 @@ def parse_ics(self, overwrite_events=True):
343349
event_dict["start_time"] = _fix_timezone(event["dtstart"].dt, self.time_zone)
344350
if "DTEND" in event:
345351
event_dict["end_time"] = _fix_timezone(event["dtend"].dt, self.time_zone)
352+
if event_dict["start_time"].hour == 0 \
353+
and event_dict["start_time"].minute == 0 \
354+
and (event_dict["end_time"] - event_dict["start_time"]) == timedelta(days=1):
355+
event_dict["all_day"] = True
356+
else:
357+
event_dict["all_day"] = False
346358

347359
event_dict["repeats"] = False
348360
if "RRULE" in event:
@@ -355,13 +367,6 @@ def parse_ics(self, overwrite_events=True):
355367
event_dict["repeat_day"] = event_dict["start_time"].day
356368
event_dict["repeat_month"] = event_dict["start_time"].month
357369

358-
if event_dict["start_time"].hour == 0 \
359-
and event_dict["start_time"].minute == 0 \
360-
and (event_dict["end_time"] - event_dict["start_time"]) == timedelta(days=1):
361-
event_dict["all_day"] = True
362-
else:
363-
event_dict["all_day"] = False
364-
365370
if "BYDAY" in rep_dict:
366371
event_dict["repeat_day"] = rep_dict["BYDAY"][0]
367372
elif "BYMONTHDAY" in rep_dict:

0 commit comments

Comments
 (0)