From 73c584c236f1e85640d551f0034f2ce037186d8c Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Mon, 16 Nov 2026 08:29:18 +0100 Subject: [PATCH 1/4] fix: same defaults for interactive commands The `plann interactive` subcommands had their own defaults, different from those of the functions `interactive manage-tasks` calls, so the same check behaved differently depending on how it was started. The click options now read the defaults from the function signatures. check-due looks 24 hours ahead in both cases. Prompt: There are some tasks on the calendar now like laundry and dishwash that was not picked up by `plann interactive manage-tasks`. Please investigat (sic) Followup-Prompt: Consolidate code and make 24 hours the default for check-due Assisted-By: Claude Opus 5.5 Reviewed-by: Tobias Brox --- CHANGELOG.md | 4 ++++ plann/cli.py | 30 +++++++++++++++++++----------- tests/test_plann_cli.py | 28 ++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 083b4ba..d588a06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ and I do try to adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.h * `plann interactive check-pinned` goes through the past week's events pinning tasks to the calendar (as made by the panic planning in `interactive manage-tasks`) and asks if each task was done. A done task is completed (with its subtasks), and its event is marked as confirmed; its other pins may be cancelled. If not done, the event is cancelled. It is also run first in `interactive manage-tasks`. https://github.com/pycalendar/plann/pull/89 +### Changed + +* The `plann interactive` subcommands now have the same defaults as when `interactive manage-tasks` runs them, except `dismiss-panic --hours-per-day`, which `manage-tasks` runs with 24 and then 14. `check-due` looks 24 hours ahead (was 16) and goes through at most 16 tasks (was unlimited); `split-huge-tasks` and `split-high-pri-tasks` look 60 days and 640 tasks ahead (was 30 days and 32 tasks). + ### Fixed * `interactive manage-tasks`: a parent task postponed together with its child could be postponed once more in its own turn, and with caldav 3.6 this crashed with a "412 Precondition Failed" error. It is now skipped, with a note. A task changed on the server in the meantime is reloaded before it is postponed. diff --git a/plann/cli.py b/plann/cli.py index 8f5773c..093cad0 100755 --- a/plann/cli.py +++ b/plann/cli.py @@ -18,6 +18,7 @@ ## `from plann import ...` import datetime +import inspect import logging import sys @@ -68,6 +69,13 @@ list_type = list + +def _default(func, param): + """The default value of a parameter of func - lets a click option + share its default with the implementation, which `manage-tasks` + calls directly""" + return inspect.signature(func).parameters[param].default + ## TODO: ## should make some subclasses of click.ParamType: @@ -706,8 +714,8 @@ def manage_tasks(ctx): _agenda(ctx) @interactive.command() -@click.option('--limit', type=int, help='If more than limit overdue tasks are found, probably we should do a mass procrastination rather than going through one and one task') -@click.option('--lookahead', help='Look-ahead time - check tasks that needs to be completed in the near future', default='+16h') +@click.option('--limit', type=int, help='If more than limit overdue tasks are found, probably we should do a mass procrastination rather than going through one and one task', default=_default(_check_due, 'limit')) +@click.option('--lookahead', help='Look-ahead time - check tasks that needs to be completed in the near future', default=_default(_check_due, 'lookahead')) @click.pass_context def check_due(ctx, limit, lookahead): """ @@ -716,7 +724,7 @@ def check_due(ctx, limit, lookahead): return _check_due(ctx, limit, lookahead) @interactive.command() -@click.option('--lookback', help='how far back to look for events pinning tasks to the calendar', default='7d') +@click.option('--lookback', help='how far back to look for events pinning tasks to the calendar', default=_default(_check_pinned, 'lookback')) @click.pass_context def check_pinned(ctx, lookback): """ @@ -729,9 +737,9 @@ def check_pinned(ctx, lookback): @interactive.command() @click.option('--hours-per-day', help='how many hours per day you expect to be able to dedicate to those tasks/events', default=4) -@click.option('--lookahead', help='timespan to investigate', default='60d') +@click.option('--lookahead', help='timespan to investigate', default=_default(_dismiss_panic, 'lookahead')) @click.pass_context -def dismiss_panic(ctx, hours_per_day, lookahead='60d'): +def dismiss_panic(ctx, hours_per_day, lookahead): """Checks workload, procrastinates tasks Search for panic points, checks if they can be solved by @@ -741,9 +749,9 @@ def dismiss_panic(ctx, hours_per_day, lookahead='60d'): @interactive.command() -@click.option('--threshold', help='tasks with a higher estimate than this should be split into subtasks', default='4h') -@click.option('--max-lookahead', help='ignore tasks further in the future than this', default='30d') -@click.option('--limit-lookahead', help='only consider the first x tasks', default=32) +@click.option('--threshold', help='tasks with a higher estimate than this should be split into subtasks', default=_default(_split_huge_tasks, 'threshold')) +@click.option('--max-lookahead', help='ignore tasks further in the future than this', default=_default(_split_huge_tasks, 'max_lookahead')) +@click.option('--limit-lookahead', help='only consider the first x tasks', default=_default(_split_huge_tasks, 'limit_lookahead')) @click.pass_context def split_huge_tasks(ctx, threshold, max_lookahead, limit_lookahead): """ @@ -752,9 +760,9 @@ def split_huge_tasks(ctx, threshold, max_lookahead, limit_lookahead): return _split_huge_tasks(ctx, threshold, max_lookahead, limit_lookahead) @interactive.command() -@click.option('--max-lookahead', help='ignore tasks further in the future than this', default='30d') -@click.option('--threshold', help='tasks with this or lower priority should always have children', default=2) -@click.option('--limit-lookahead', help='only consider the first x tasks', default=32) +@click.option('--max-lookahead', help='ignore tasks further in the future than this', default=_default(_split_high_pri_tasks, 'max_lookahead')) +@click.option('--threshold', help='tasks with this or lower priority should always have children', default=_default(_split_high_pri_tasks, 'threshold')) +@click.option('--limit-lookahead', help='only consider the first x tasks', default=_default(_split_high_pri_tasks, 'limit_lookahead')) @click.pass_context def split_high_pri_tasks(ctx, threshold, max_lookahead, limit_lookahead): """Tasks with very high priority (1,2) indicates a hard DUE that diff --git a/tests/test_plann_cli.py b/tests/test_plann_cli.py index 911a0b8..3d706d8 100644 --- a/tests/test_plann_cli.py +++ b/tests/test_plann_cli.py @@ -1,9 +1,11 @@ ## Check https://click.palletsprojects.com/en/8.1.x/testing/ +import inspect from datetime import datetime, timedelta from unittest.mock import patch import caldav +import pytest from caldav import Todo from click.testing import CliRunner @@ -14,6 +16,32 @@ from tests.test_freebusy import FakeCalendar, _event, oslo +@pytest.mark.parametrize("command, function", [ + ('check-pinned', '_check_pinned'), + ('check-due', '_check_due'), + ('dismiss-panic', '_dismiss_panic'), + ('split-huge-tasks', '_split_huge_tasks'), + ('split-high-pri-tasks', '_split_high_pri_tasks'), +]) +def test_interactive_cli_defaults_match_manage_tasks(command, function): + """`plann interactive X` and `manage-tasks` (which calls the + underlying function with its defaults) should behave the same""" + signature = inspect.signature(getattr(commands_mod, function)) + calls = [] + with patch.object(cli_mod, function, lambda *a: calls.append(signature.bind(*a).arguments)), \ + patch.object(cli_mod, '_discover_calendars', lambda kwargs: []): + res = CliRunner().invoke(cli, ['interactive', command]) + assert res.exit_code == 0, res.output + [args] = calls + for name, param in signature.parameters.items(): + if param.default is not inspect.Parameter.empty: + assert args[name] == param.default, name + + +def test_check_due_looks_24h_ahead(): + assert inspect.signature(commands_mod._check_due).parameters['lookahead'].default == '24h' + + def _make_todo(uid, *, category=False, due=False, priority=False, dtstart=False): lines = ["UID:" + uid, "SUMMARY:task " + uid, "STATUS:NEEDS-ACTION"] if category: From 28bad509558961cf6ed6c051d417434fe5c32523 Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Mon, 16 Nov 2026 08:29:27 +0100 Subject: [PATCH 2/4] fix: a bare hour is a time today, not a day `--set-dtstart=14` was parsed by dateparser as the 14th of the month, giving an all-day task where 14:00 local time was meant. A bare number of one or two digits below 24 is now an hour today in the implicit timezone, in any date or time argument. Prompts: > They shouldn't have an all-day DUE, it should be a timestamp. > `dtstart=14` was meant to be 14:00 laptop time > (on the finding that "0001" became an hour and 24-31 stayed a day of > the month) Let 1-2 digits only mean "hour" and not "day of the > month". Though, maybe we should avoid special logics (sic) in the plann > cli and rather just rely on the decisions done in dateparser? For me > it was very confusing that an "all day"-task for the 14th of December > was created when I wanted a task due at 14:00 today, but then again, > plann should work for the public at large and not only for me. Assisted-By: Claude Opus 5.5 Reviewed-by: Tobias Brox --- CHANGELOG.md | 1 + plann/timespec.py | 5 +++++ tests/test_timespec.py | 20 ++++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d588a06..ae399d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and I do try to adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.h ### Fixed +* A bare hour (one or two digits, 0-23) in a date or time argument, like `--set-dtstart=14`, means 14:00 today in the implicit timezone. It was taken as the 14th of the month, giving an all-day task. * `interactive manage-tasks`: a parent task postponed together with its child could be postponed once more in its own turn, and with caldav 3.6 this crashed with a "412 Precondition Failed" error. It is now skipped, with a note. A task changed on the server in the meantime is reloaded before it is postponed. * `interactive manage-tasks` no longer stops with a traceback when the server refuses to store a task it postpones, e.g. with "423 Locked" from a Xandikos server busy with another write. The task is reported and the rest are still postponed. diff --git a/plann/timespec.py b/plann/timespec.py index 9b3003d..2e5dd24 100644 --- a/plann/timespec.py +++ b/plann/timespec.py @@ -122,6 +122,11 @@ def _parse_dt(input, return_type=None): return input if input == 'now': ret = _now() + elif input.isdigit() and len(input) <= 2 and int(input) < 24: + ## a bare hour, i.e. `--set-dtstart=14` means 14:00 today. + ## dateparser would take it as a day of the month. + ret = _now().replace(hour=int(input), minute=0, second=0, microsecond=0) + return ret.date() if return_type is datetime.date else ret elif input.startswith('+'): ret = parse_add_dur(_now(), input[1:]) else: diff --git a/tests/test_timespec.py b/tests/test_timespec.py index a1b0393..f9fd686 100644 --- a/tests/test_timespec.py +++ b/tests/test_timespec.py @@ -240,6 +240,26 @@ def test_invalid_raises(self): with pytest.raises(ValueError): parse_dt("not a date at all !!!!") + @pytest.mark.parametrize("hour", ["0", "9", "09", "14", "23"]) + def test_bare_hour(self, hour): + """A bare number 0-23 is an hour today in the implicit timezone, + not a day of the month (``--set-dtstart=14`` means 14:00)""" + tz.implicit_timezone = "Europe/Oslo" + result = parse_dt(hour) + assert result == datetime.now(OSLO).replace( + hour=int(hour), minute=0, second=0, microsecond=0) + + def test_bare_number_with_leading_zeros_is_not_an_hour(self): + """Only one or two digits are an hour; "0001" is something else""" + tz.implicit_timezone = "Europe/Oslo" + result = parse_dt("0001") + assert not (isinstance(result, datetime) and result.date() == datetime.now(OSLO).date() and result.hour == 1) + + def test_bare_day_of_month(self): + """Numbers that cannot be an hour are still a day of the month""" + tz.implicit_timezone = "Europe/Oslo" + assert parse_dt("28").day == 28 + class TestDurationGrammar: """The [smhdwy] relative-duration grammar is centralised in timespec.py.""" From 0c318696e1063bd702685124717b8a4df8db1a28 Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Mon, 16 Nov 2026 08:54:49 +0100 Subject: [PATCH 3/4] fix: check-due tells when tasks are left out check-due cut its list off at 16 tasks without a word, and as the list is sorted on priority, the low-priority chores were never shown. The limit now applies after the client side filtering, and when tasks are left out it says how many are due and points at dismiss-panic. Prompt: Why is the 16-task-limit there? It would probably make more sense to show all tasks? Followup-Prompt: Ok, [warn when check-due leaves tasks out] Assisted-By: Claude Opus 5.5 Reviewed-by: Tobias Brox --- CHANGELOG.md | 1 + plann/commands.py | 18 ++++++++++-------- tests/test_plann_cli.py | 26 ++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae399d9..a6ad940 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and I do try to adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.h ### Fixed +* `interactive check-due` (also run by `interactive manage-tasks`) silently left out the due tasks beyond the first 16, usually the low-priority ones. It now says how many tasks are due when it cannot show them all. * A bare hour (one or two digits, 0-23) in a date or time argument, like `--set-dtstart=14`, means 14:00 today in the implicit timezone. It was taken as the 14th of the month, giving an all-day task. * `interactive manage-tasks`: a parent task postponed together with its child could be postponed once more in its own turn, and with caldav 3.6 this crashed with a "412 Precondition Failed" error. It is now skipped, with a note. A task changed on the server in the meantime is reloaded before it is postponed. * `interactive manage-tasks` no longer stops with a traceback when the server refuses to store a task it postpones, e.g. with "423 Locked" from a Xandikos server busy with another write. The task is reported and the rest are still postponed. diff --git a/plann/commands.py b/plann/commands.py index 386d1e2..e904c11 100644 --- a/plann/commands.py +++ b/plann/commands.py @@ -490,17 +490,19 @@ def _agenda(ctx): def _check_due(ctx, limit=16, lookahead='24h'): end_ = parse_add_dur(datetime.datetime.now(), lookahead) - _select(ctx=ctx, todo=True, end=end_, limit=limit, sort_key=['{PRIORITY:?0?} {DTSTART:?{DUE:?(0000)?}?%F %H:%M:%S}']) - objs = ctx.obj['objs'] - for obj in objs: + _select(ctx=ctx, todo=True, end=end_, sort_key=['{PRIORITY:?0?} {DTSTART:?{DUE:?(0000)?}?%F %H:%M:%S}']) + def is_due(obj): ## client side filtering in case the server returns too much ## TODO: should be moved to the caldav library - ## TODO: consider the limit ... we may risk that nothing comes up due to the limit above comp = obj.icalendar_component - dtstart = comp.get('dtstart') or comp.get('due') - dtstart = _ensure_ts(dtstart) - if dtstart.strftime("%F%H%M") > end_.strftime("%F%H%M"): - continue + dtstart = _ensure_ts(comp.get('dtstart') or comp.get('due')) + return dtstart.strftime("%F%H%M") <= end_.strftime("%F%H%M") + objs = [obj for obj in ctx.obj['objs'] if is_due(obj)] + if limit is not None and len(objs) > limit: + click.echo(f"{len(objs)} tasks are due, only the first {limit} are shown here. " + "Consider postponing many at once with `plann interactive dismiss-panic`.") + objs = objs[:limit] + for obj in objs: _interactive_edit(obj) def _pinned_task_parents(event): diff --git a/tests/test_plann_cli.py b/tests/test_plann_cli.py index 3d706d8..190fa76 100644 --- a/tests/test_plann_cli.py +++ b/tests/test_plann_cli.py @@ -65,6 +65,32 @@ def __init__(self): self.obj = {'calendars': [], 'objs': []} +def _check_due_with(todos, limit): + """run _check_due over the given todos, return the ones it asks about""" + def select(ctx, **kwargs): + assert 'limit' not in kwargs, "the limit should apply after the client side filtering" + ctx.obj['objs'] = list(todos) + asked = [] + with patch.object(commands_mod, '_select', select), \ + patch.object(commands_mod, '_interactive_edit', asked.append): + commands_mod._check_due(_FakeCtx(), limit=limit) + return asked + + +def test_check_due_warns_when_tasks_are_left_out(capsys): + todos = [_make_todo(f"t{i}", due=True, dtstart=True) for i in range(5)] + assert _check_due_with(todos, limit=3) == todos[:3] + out = capsys.readouterr().out + assert '5 tasks are due' in out + assert 'dismiss-panic' in out + + +def test_check_due_no_warning_within_limit(capsys): + todos = [_make_todo(f"t{i}", due=True, dtstart=True) for i in range(3)] + assert _check_due_with(todos, limit=3) == todos + assert capsys.readouterr().out == '' + + def test_todos_missing(): """_todos_missing keeps only the tasks where the property is absent.""" with_cat = _make_todo('a', category=True) From e2c00a4c8fb5d116392f545bba0aafd7298123b2 Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Mon, 16 Nov 2026 19:08:37 +0100 Subject: [PATCH 4/4] fix: task with date DTSTART and timestamp DUE The sanity check on mismatched date types in selections always wrote to DTEND, which a VTODO with DUE does not have, so it crashed with KeyError. It now converts only the date value, to local midnight in the implicit timezone (floating if the other value is floating), replacing the property so VALUE=DATE goes away. The time of day on the timestamp used to be truncated; it is kept. The check that DTSTART is not after DTEND/DUE no longer crashes when one is floating and the other is not. Prompt: (traceback pasted: KeyError: 'DTEND' in __select, from _split_huge_tasks in interactive manage-tasks, after the log line "has non-matching types on dtstart and dtend/due") Assisted-By: Claude Opus 5.5 Reviewed-by: Tobias Brox --- CHANGELOG.md | 1 + plann/commands.py | 34 ++++++++++++++++++++++-------- tests/test_commands.py | 47 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6ad940..7dca51a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and I do try to adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.h ### Fixed +* A task with DTSTART as a date and DUE as a timestamp (or the other way around) made `interactive manage-tasks` and other selections crash with `KeyError: 'DTEND'`. The date is now made a timestamp at local midnight; the time of day on the other one is kept (it used to be dropped), and the result is valid iCalendar. * `interactive check-due` (also run by `interactive manage-tasks`) silently left out the due tasks beyond the first 16, usually the low-priority ones. It now says how many tasks are due when it cannot show them all. * A bare hour (one or two digits, 0-23) in a date or time argument, like `--set-dtstart=14`, means 14:00 today in the implicit timezone. It was taken as the 14th of the month, giving an all-day task. * `interactive manage-tasks`: a parent task postponed together with its child could be postponed once more in its own turn, and with caldav 3.6 this crashed with a "412 Precondition Failed" error. It is now skipped, with a note. A task changed on the server in the meantime is reloaded before it is postponed. diff --git a/plann/commands.py b/plann/commands.py index e904c11..380a5db 100644 --- a/plann/commands.py +++ b/plann/commands.py @@ -220,15 +220,7 @@ def __select(ctx, extend_objects=False, all=None, uid=[], abort_on_missing_uid=N ## some sanity checks for obj in ctx.obj['objs']: - comp = obj.icalendar_component - dtstart = comp.get('dtstart') - dtend = comp.get('dtend') or comp.get('due') - if dtstart and dtend and isinstance(dtstart.dt, datetime.datetime) != isinstance(dtend.dt, datetime.datetime): - logging.error(f"task with uuid {comp['uid']} has non-matching types on dtstart and dtend/due, setting both to timestamps") - comp['dtstart'].dt = datetime.datetime(dtstart.dt.year, dtstart.dt.month, dtstart.dt.day) - comp['dtend'].dt = datetime.datetime(dtend.dt.year, dtend.dt.month, dtend.dt.day) - elif dtstart and dtend and dtstart.dt > dtend.dt: - logging.error(f"task with uuid {comp['uid']} as dtstart after dtend/due") + _fix_mismatched_date_types(obj.icalendar_component) ## I need a way to copy time information from one calendar to another ## (typically between private and work calendars) without carrying over @@ -244,6 +236,30 @@ def __select(ctx, extend_objects=False, all=None, uid=[], abort_on_missing_uid=N if attr == 'SUMMARY': comp[attr] = freebusyhack +def _fix_mismatched_date_types(comp): + """If one of DTSTART and DTEND/DUE is a date and the other a timestamp, + turn the date into a timestamp at midnight in the implicit timezone + (floating, if the timestamp is floating), so they can be compared. The + time of day on the timestamp is kept. Logs an error if DTSTART comes + after DTEND/DUE.""" + endkey = 'DTEND' if 'DTEND' in comp else 'DUE' + dtstart = comp.get('DTSTART') + dtend = comp.get(endkey) + if not (dtstart and dtend): + return + start_is_ts = isinstance(dtstart.dt, datetime.datetime) + if start_is_ts != isinstance(dtend.dt, datetime.datetime): + logging.error(f"task with uuid {comp['uid']} has non-matching types on dtstart and dtend/due, setting both to timestamps") + date_key, d, other = (endkey, dtend.dt, dtstart.dt) if start_is_ts else ('DTSTART', dtstart.dt, dtend.dt) + new_ts = datetime.datetime(d.year, d.month, d.day) + if other.tzinfo: + new_ts = _ensure_ts(d) + ## replace the property rather than setting .dt, so VALUE=DATE goes away + comp.pop(date_key) + comp.add(date_key, new_ts) + elif _ensure_ts(dtstart.dt) > _ensure_ts(dtend.dt): + logging.error(f"task with uuid {comp['uid']} as dtstart after dtend/due") + def _categories_in_use(objs): categories = set() for obj in objs: diff --git a/tests/test_commands.py b/tests/test_commands.py index 6ffdd6d..a1bb29e 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -23,3 +23,50 @@ def _todo(uid, extra): missing = _todos_missing([absent, zero, real], 'priority') uids = {x.icalendar_component['UID'] for x in missing} assert uids == {'no-priority', 'zero-priority'} + + +def _vtodo(uid, extra): + return Todo(data=( + "BEGIN:VCALENDAR\nVERSION:2.0\nBEGIN:VTODO\n" + f"UID:{uid}\nSUMMARY:{uid}\n{extra}END:VTODO\nEND:VCALENDAR")) + + +def test_mismatched_date_types_fixed_on_due(monkeypatch): + """A VTODO with DTSTART as a date and DUE as a timestamp has no DTEND. + The sanity check must fix DUE, not crash with KeyError on DTEND - and + must keep the time of day already on DUE. The date becomes local + midnight in the implicit timezone, also when DUE is in UTC.""" + import datetime + from zoneinfo import ZoneInfo + + from plann import timespec + from plann.commands import _fix_mismatched_date_types + + monkeypatch.setitem(vars(timespec.tz), "_implicit_timezone", ZoneInfo("America/New_York")) + comp = _vtodo('mixed', "DTSTART;VALUE=DATE:20261116\nDUE:20261118T140000Z\n").icalendar_component + _fix_mismatched_date_types(comp) + assert 'DTEND' not in comp + assert comp['DTSTART'].dt == datetime.datetime(2026, 11, 16, tzinfo=ZoneInfo("America/New_York")) + assert comp['DTSTART'].dt.date() == datetime.date(2026, 11, 16) + assert comp['DUE'].dt == datetime.datetime(2026, 11, 18, 14, 0, tzinfo=datetime.timezone.utc) + assert b'VALUE=DATE' not in comp.to_ical() + + +def test_mismatched_date_types_floating_stays_floating(): + """With a floating timestamp on the other side, the date becomes a + floating midnight too""" + import datetime + + from plann.commands import _fix_mismatched_date_types + + comp = _vtodo('floating', "DTSTART:20261116T100000\nDUE;VALUE=DATE:20261118\n").icalendar_component + _fix_mismatched_date_types(comp) + assert comp['DUE'].dt == datetime.datetime(2026, 11, 18) + + +def test_aware_vs_floating_does_not_crash(): + """A floating DTSTART and a UTC DUE cannot be compared directly""" + from plann.commands import _fix_mismatched_date_types + + comp = _vtodo('aware-floating', "DTSTART:20261119T100000\nDUE:20261118T140000Z\n").icalendar_component + _fix_mismatched_date_types(comp)