Fix repetition on dates with start+end times.
This commit is contained in:
parent
63bb1e67e0
commit
a67bde58d0
@ -960,6 +960,10 @@ class OrgTime:
|
||||
self.time = ts
|
||||
self.end_time = end_time
|
||||
|
||||
@property
|
||||
def repetition(self):
|
||||
return self.time.repetition
|
||||
|
||||
@property
|
||||
def duration(self):
|
||||
if self.end_time is None:
|
||||
@ -982,6 +986,10 @@ class OrgTime:
|
||||
else:
|
||||
return None
|
||||
|
||||
repetition = None
|
||||
if m.group("repetition"):
|
||||
repetition = m.group("repetition").strip()
|
||||
|
||||
if m.group("end_hour"):
|
||||
return OrgTime(
|
||||
Timestamp(
|
||||
@ -992,6 +1000,7 @@ class OrgTime:
|
||||
m.group("dow"),
|
||||
int(m.group("start_hour")),
|
||||
int(m.group("start_minute")),
|
||||
repetition=repetition,
|
||||
),
|
||||
Timestamp(
|
||||
active,
|
||||
@ -1013,7 +1022,7 @@ class OrgTime:
|
||||
m.group("dow"),
|
||||
int(m.group("start_hour")) if m.group("start_hour") else None,
|
||||
int(m.group("start_minute")) if m.group("start_minute") else None,
|
||||
m.group("repetition").strip() if m.group("repetition") else None,
|
||||
repetition=repetition,
|
||||
)
|
||||
)
|
||||
|
||||
@ -1047,7 +1056,7 @@ def timestamp_to_string(ts: Timestamp, end_time: Union[Timestamp, None] = None)
|
||||
base=base, hour=end_time.hour, minute=end_time.minute
|
||||
)
|
||||
|
||||
if ts.repetition:
|
||||
if ts.repetition is not None:
|
||||
base = base + " " + ts.repetition
|
||||
|
||||
if ts.active:
|
||||
|
@ -19,3 +19,6 @@ SCHEDULED: <2020-12-12 Sáb> CLOSED: <2020-12-13 Dom> DEADLINE: <2020-12-14 Lun>
|
||||
|
||||
** Scheduled for time range
|
||||
SCHEDULED: <2020-12-15 Mar 00:05-00:10>
|
||||
|
||||
** Scheduled periodic
|
||||
SCHEDULED: <2020-12-15 Mar 00:05-00:10 ++1w>
|
||||
|
@ -418,6 +418,20 @@ class TestSerde(unittest.TestCase):
|
||||
Timestamp(True, 2020, 12, 15, "Mar", 0, 10),
|
||||
)
|
||||
|
||||
hl_schedule_range = hl.children[1]
|
||||
self.assertEqual(
|
||||
hl_schedule_range.scheduled.time,
|
||||
Timestamp(True, 2020, 12, 15, "Mar", 0, 5, '++1w')
|
||||
)
|
||||
self.assertEqual(
|
||||
hl_schedule_range.scheduled.end_time,
|
||||
Timestamp(True, 2020, 12, 15, "Mar", 0, 10),
|
||||
)
|
||||
self.assertEqual(
|
||||
hl_schedule_range.scheduled.repetition,
|
||||
'++1w',
|
||||
)
|
||||
|
||||
def test_update_info_file_05(self):
|
||||
with open(os.path.join(DIR, "05-dates.org")) as f:
|
||||
orig = f.read()
|
||||
|
Loading…
Reference in New Issue
Block a user