Skip to content

Commit 9f738da

Browse files
Merge pull request #5889 from cylc/8.2.x-sync
🤖 Merge 8.2.x-sync into master
2 parents ad66532 + 8f975c4 commit 9f738da

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

changes.d/5885.fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed bug in using a final cycle point with chained offsets e.g. 'final cycle point = +PT6H+PT1S'.

cylc/flow/cycling/iso8601.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -895,14 +895,23 @@ def get_dump_format():
895895
def get_point_relative(offset_string, base_point):
896896
"""Create a point from offset_string applied to base_point."""
897897
try:
898-
interval = ISO8601Interval(str(interval_parse(offset_string)))
898+
operator = '+'
899+
base_point_relative = base_point
900+
for part in re.split(r'(\+|-)', offset_string):
901+
if part == '+' or part == '-':
902+
operator = part
903+
elif part != '':
904+
interval = interval_parse(part)
905+
if operator == '-':
906+
interval *= -1
907+
base_point_relative += ISO8601Interval(str(interval))
908+
return base_point_relative
899909
except IsodatetimeError:
910+
# It's a truncated time point rather than an interval
900911
return ISO8601Point(str(
901912
WorkflowSpecifics.abbrev_util.parse_timepoint(
902913
offset_string, context_point=point_parse(base_point.value))
903914
))
904-
else:
905-
return base_point + interval
906915

907916

908917
def interval_parse(interval_string):

tests/unit/test_config.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,17 @@ def test_process_startcp(
536536
None,
537537
id="Relative fcp"
538538
),
539+
pytest.param(
540+
ISO8601_CYCLING_TYPE,
541+
{
542+
'initial cycle point': '2017-02-11',
543+
'final cycle point': '+P4D+PT3H-PT2H',
544+
},
545+
None,
546+
'20170215T0100+0530',
547+
None,
548+
id="Relative fcp chained"
549+
),
539550
pytest.param(
540551
ISO8601_CYCLING_TYPE,
541552
{
@@ -1504,11 +1515,7 @@ def test_zero_interval(
15041515
('1988-02-29', '+P1M+P1Y', '1989-03-29'),
15051516
('1910-08-14', '+P2D-PT6H', '1910-08-15T18:00'),
15061517
('1850-04-10', '+P1M-P1D+PT1H', '1850-05-09T01:00'),
1507-
pytest.param(
1508-
'1066-10-14', '+PT1H+PT1M', '1066-10-14T01:01',
1509-
marks=pytest.mark.xfail
1510-
# https://github.com/cylc/cylc-flow/issues/5047
1511-
),
1518+
('1066-10-14', '+PT1H+PT1M', '1066-10-14T01:01'),
15121519
]
15131520
)
15141521
def test_chain_expr(

0 commit comments

Comments
 (0)