Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Searching also returns full-day events of adjacent days

未关闭
#545 6 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
python
领域
api

调研方向

Start by reproducing the reported cases with the supplied calendar.search(start=..., end=..., event=True, expand=True) calls, then read the implementation and documentation for search() and its handling of full-day events and timezones. Done means searches return the expected events for the reported dates and timezone variants; clarify the intended CalDAV behavior before choosing a fix.

由索引模型根据 Issue 内容生成。

描述

Problem:

I'm trying to find all events that occur today or later. In some cases, events from yesterday are returned.

I'm not completely sure if this is a bug or just the way CalDAV works, but at least it's not what I expected.

Test setup: There are there are three full-day events in the calendar, on 18.,19.,20.08.25. I created them with Thunderbird, the server is Baikal. I did not specify a timezone (nor could I for full-day events).

Code:

from datetime import datetime, timedelta, date, timezone
import caldav

url = "..."
username = "..."
password = "..."
client = caldav.DAVClient(url, username=username, password=password)
principal = client.principal()
calendars = principal.calendars()
calendar = next(cal for cal in calendars if cal.name == "Test-Cal")

# there are three full-day events in the calendar, on 18.,19.,20.08.25

dates = [
    datetime(year=2025, month=8, day=17, hour=0, minute=10),
    datetime(year=2025, month=8, day=17, hour=0, minute=10, tzinfo=timezone(timedelta(hours=2))),
    datetime(year=2025, month=8, day=17, hour=0, minute=10, tzinfo=timezone(timedelta(hours=0))),
    datetime(year=2025, month=8, day=17, hour=0, minute=0),
    datetime(year=2025, month=8, day=17, hour=0, minute=0, tzinfo=timezone(timedelta(hours=2))),
    datetime(year=2025, month=8, day=17, hour=0, minute=0, tzinfo=timezone(timedelta(hours=0))),
]

for test_time in dates:
    print("Testing with", test_time)
    print("    | 18 | 19 | 20 |")
    for i in range(4):
        print(f" +{i} |", end="")
        t = test_time + timedelta(days=i)
        results = calendar.search(start=t, end=t + timedelta(days=1), event=True, expand=True, sort_keys="dtstart")
        summaries = [e.instance.vevent.summary.value for e in results]
        for j in range(1, 4):
            if f"Test{j}" in summaries:
                print(f" X  |", end="")
            else:
                print(f"    |", end="")
        print()

Output (with comments from me). Expected would be a diagonal in the last three lines.

Testing with 2025-08-17 00:10:00 //my actual code, running in UTC+2 just after midnight
    | 18 | 19 | 20 |
 +0 |    |    |    |
 +1 | X  |    |    |
 +2 | X  | X  |    | //the bug I noticed
 +3 |    | X  | X  |
Testing with 2025-08-17 00:10:00+02:00 //add the timezone explicitly
    | 18 | 19 | 20 |
 +0 |    |    |    |
 +1 | X  |    |    |
 +2 | X  | X  |    | //no change
 +3 |    | X  | X  |
Testing with 2025-08-17 00:10:00+00:00 //now in UTC
    | 18 | 19 | 20 |
 +0 | X  |    |    | //this is correct b/c 00:10+1d contains the next day!
 +1 | X  | X  |    |
 +2 |    | X  | X  |
 +3 |    |    | X  |
Testing with 2025-08-17 00:00:00 // test on exactly midnight
    | 18 | 19 | 20 |
 +0 |    |    |    |
 +1 | X  |    |    |
 +2 | X  | X  |    | //same problem
 +3 |    | X  | X  |
Testing with 2025-08-17 00:00:00+02:00
    | 18 | 19 | 20 |
 +0 |    |    |    |
 +1 | X  |    |    |
 +2 | X  | X  |    | //dito
 +3 |    | X  | X  |
Testing with 2025-08-17 00:00:00+00:00 //midnight, UTC
    | 18 | 19 | 20 |
 +0 |    |    |    |
 +1 | X  |    |    | //correct!
 +2 |    | X  |    |
 +3 |    |    | X  |

This is the pattern I could make up from this:

  • without timezone infos, the datetime gets interpreted in the local timezone
  • before matching against full-day events in the calendar, dates are shifted to UTC
  • this causes the dates to move to the previous day

This is just my guesswork, someone with more insight to CalDAV can probably make more sense out of this.

主要语言
Python
星标
412
派生
113
平均合并
1 天 14 小时
30 天内合并 PR
26

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

python-caldav/caldav 的其他 Issue

查看 python-caldav/caldav 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。