def test_utcrange(self): self.assertEqual( OrgFormat.utcrange( time.struct_time([1980,12,31,23,59,58,0,0,0]), time.struct_time([1981,1,15,15,30,02,0,0,0]), ), OrgFormat.datetimerange( time.struct_time([1980,12,31,23,59,58,0,0,0]), time.struct_time([1981,1,15,15,30,02,0,0,0]), ) ) self.assertEqual( OrgFormat.utcrange( time.struct_time([1980,12,31,23,59,0,0,0,0]), time.struct_time([1981,1,15,15,30,02,0,0,0]), ), OrgFormat.datetimerange( time.struct_time([1980,12,31,23,59,0,0,0,0]), time.struct_time([1981,1,15,15,30,02,0,0,0]), ) ) self.assertEqual( OrgFormat.utcrange( time.struct_time([1980,12,31,0,0,0,0,0,0]), time.struct_time([1981,1,15,0,0,0,0,0,0]), ), OrgFormat.daterange( time.struct_time([1980,12,31,23,59,0,0,0,0]), time.struct_time([1981,1,15,15,30,02,0,0,0]), ) )
def test_utcrange(self): self.assertEqual( OrgFormat.utcrange( time.struct_time([1980, 12, 31, 23, 59, 58, 0, 0, 0]), time.struct_time([1981, 1, 15, 15, 30, 0o2, 0, 0, 0]), ), OrgFormat.datetimerange( time.struct_time([1980, 12, 31, 23, 59, 58, 0, 0, 0]), time.struct_time([1981, 1, 15, 15, 30, 0o2, 0, 0, 0]), )) self.assertEqual( OrgFormat.utcrange( time.struct_time([1980, 12, 31, 23, 59, 0, 0, 0, 0]), time.struct_time([1981, 1, 15, 15, 30, 0o2, 0, 0, 0]), ), OrgFormat.datetimerange( time.struct_time([1980, 12, 31, 23, 59, 0, 0, 0, 0]), time.struct_time([1981, 1, 15, 15, 30, 0o2, 0, 0, 0]), )) self.assertEqual( OrgFormat.utcrange( time.struct_time([1980, 12, 31, 0, 0, 0, 0, 0, 0]), time.struct_time([1981, 1, 15, 0, 0, 0, 0, 0, 0]), ), OrgFormat.daterange( time.struct_time([1980, 12, 31, 23, 59, 0, 0, 0, 0]), time.struct_time([1981, 1, 15, 15, 30, 0o2, 0, 0, 0]), ))
def __get_datetime_range(self, dtstart, dtend): """ @return string: Datetime - Range in Org Format """ begin_tupel = OrgFormat.datetupelutctimestamp(dtstart) end_tupel = OrgFormat.datetupelutctimestamp(dtend) # handle "all-day" - events if begin_tupel.tm_sec == 0 and \ begin_tupel.tm_min == 0 and \ begin_tupel.tm_hour == 0 and \ end_tupel.tm_sec == 0 and \ end_tupel.tm_min == 0 and \ end_tupel.tm_hour == 0: # we have to subtract 1 day to get the correct dates end_tupel = time.localtime(time.mktime(end_tupel) - 24 * 60 * 60) return OrgFormat.utcrange(begin_tupel, end_tupel)