# iCalendar

**iCalendar** 是一种由互联网工程任务组（IETF）标准化的文本格式，用于传递日历与日程安排数据——事件、待办事项、日志条目以及空闲/忙碌信息——且不依赖任何特定的日历服务或协议。<sup>[1](https://www.rfc-editor.org/info/rfc5545/)</sup> 其当前核心规范为 2009 年 9 月发布的 RFC 5545，该规范废止了 1998 年的原始规范 RFC 2445<sup>[1](https://www.rfc-editor.org/info/rfc5545/)</sup><sup> • </sup><sup>[2](https://www.rfc-editor.org/info/rfc2445/)</sup>。该格式注册为 MIME 媒体类型 `text/calendar`，几乎所有主流日历产品——包括 Google Calendar、Apple Calendar 和 Microsoft Outlook——都使用它来导入、导出和订阅日历数据<sup>[3](https://icalendar.org/the-icalendar-standard-2.html)</sup>。

| 关键事实 | 详情 |
|---|---|
| 当前标准 | RFC 5545，《互联网日历与日程安排核心对象规范（iCalendar）》，2009 年 9 月；废止 RFC 2445（1998 年 11 月）<sup>[1](https://www.rfc-editor.org/info/rfc5545/)</sup> |
| 媒体类型与文件 | MIME 类型 `text/calendar`；日历数据使用 `.ics`，空闲/忙碌信息使用 `.ifb`<sup>[4](https://datatracker.ietf.org/doc/html/rfc5545)</sup> |
| 核心组件 | VCALENDAR 包装器，内含 VEVENT、VTODO、VJOURNAL、VFREEBUSY、VTIMEZONE 和 VALARM 组件<sup>[5](https://www.iana.org/assignments/icalendar)</sup> |
| 重复规则 | RRULE 属性定义重复模式；重复集合由 DTSTART、RRULE、RDATE 和 EXDATE 构建<sup>[4](https://datatracker.ietf.org/doc/html/rfc5545)</sup> |
| 字符编码 | 应用程序必须（MUST）以 UTF-8 生成 iCalendar 流，并必须（MUST）接受 UTF-8 或 US-ASCII<sup>[4](https://datatracker.ietf.org/doc/html/rfc5545)</sup> |
| 访问协议 | CalDAV（RFC 4791）要求以 iCalendar 作为日历对象资源的媒体类型<sup>[6](https://www.rfc-editor.org/info/rfc4791/)</sup> |
| JSON 替代方案 | JSCalendar（RFC 8984，2021）定义了一种 JSON 表示，旨在作为 iCalendar 的替代方案，并随时间推移成为其继任者<sup>[7](https://www.rfc-editor.org/rfc/rfc8984.html)</sup> |

## 历史

该格式源自更早的 vCalendar 行业规范，后者用于交换个人日历与日程安排信息<sup>[4](https://datatracker.ietf.org/doc/html/rfc5545)</sup>。1998 年 11 月，IETF 发布了 RFC 2445，由 Lotus 的 F. Dawson 和 Microsoft 的 D. Stenerson 通过日历与日程安排（CALSCH）工作组撰写，该规范注册了 `text/calendar` 并定义了核心对象格式<sup>[2](https://www.rfc-editor.org/info/rfc2445/)</sup>。RFC 5545 由 Oracle 的 Bernard Desruisseaux 通过 calsify 工作组编辑，于 2009 年 9 月取代了前者<sup>[1](https://www.rfc-editor.org/info/rfc5545/)</sup><sup> • </sup><sup>[8](https://datatracker.ietf.org/doc/rfc5545/)</sup>。

自 2009 年以来，核心规范由一系列扩展 RFC 更新：RFC 5546（iTIP，日程安排操作）、RFC 6868（参数值编码）、RFC 7529（非公历重复规则）、RFC 7953（可用性）、RFC 7986（新属性）、RFC 9073（事件发布扩展）、RFC 9074（VALARM 扩展）以及 RFC 9253<sup>[8](https://datatracker.ietf.org/doc/rfc5545/)</sup>。

## iCalendar 对象的结构

一个 iCalendar 对象由一系列日历属性和一个或多个日历组件构成，组织为一行行称为内容行的文本<sup>[4](https://datatracker.ietf.org/doc/html/rfc5545)</sup>。内容行以 CRLF 序列分隔，行长度不应超过 75 个八位组；更长的行通过插入一个 CRLF 后跟单个空格或制表符来折行，解析器在展开时会移除这些字符<sup>[4](https://datatracker.ietf.org/doc/html/rfc5545)</sup>。规范第 3 节定义了内容行格式、属性参数、值数据类型、对象格式、日历属性以及组件属性<sup>[4](https://datatracker.ietf.org/doc/html/rfc5545)</sup>。

一个典型对象以 `BEGIN:VCALENDAR` 开头，携带必需的日历属性如 `VERSION:2.0` 和 `PRODID`，随后是各组件。IANA 注册表列出了已注册的组件：VEVENT 用于事件，VTODO 用于待办事项，VJOURNAL 用于日志条目，VFREEBUSY 用于空闲/忙碌时间，VTIMEZONE 用于时区定义，VALARM 用于提醒，以及后来新增的 VAVAILABILITY、PARTICIPANT、VLOCATION 和 VRESOURCE<sup>[5](https://www.iana.org/assignments/icalendar)</sup>。应用程序必须忽略它们无法识别的组件类型，而导入器不应静默丢弃组件，因为那可能导致用户数据丢失<sup>[4](https://datatracker.ietf.org/doc/html/rfc5545)</sup>。

**时区。** VTIMEZONE 组件定义了某一特定时区在给定区间内的标准时间与夏令时实施规则集合。它必须包含一个 TZID 属性以及至少一个 STANDARD 或 DAYLIGHT 子组件，每个子组件携带 DTSTART、TZOFFSETFROM 和 TZOFFSETTO 属性。一个对象中可以存在多个 VTIMEZONE 组件，每个代表一个唯一的时区，这支持了诸如航班从一个时区起飞、在另一个时区降落这类事件<sup>[4](https://datatracker.ietf.org/doc/html/rfc5545)</sup>。

**提醒。** VALARM 组件指定一个音频、显示或电子邮件动作，并附带一个 TRIGGER。在电子邮件提醒中，DESCRIPTION 属性成为消息正文，SUMMARY 成为主题，发送至 ATTENDEE 属性中的地址。规范警告实现者应仔细考虑是否接受来自不可信来源的提醒组件，例如从外部订阅源导入日历对象时<sup>[4](https://datatracker.ietf.org/doc/html/rfc5545)</sup>。

## 重复规则

RRULE 属性使用 RECUR 值类型，为重复事件、待办事项、日志条目或时区定义定义规则或重复模式<sup>[4](https://datatracker.ietf.org/doc/html/rfc5545)</sup>。FREQ 规则部分是必需的，且不得出现多次；可选部分如 UNTIL、COUNT、INTERVAL 以及 BYxxx 修饰符塑造模式。规则中未包含的信息，如月中的日期或一天中的时间，从 DTSTART 属性派生<sup>[4](https://datatracker.ietf.org/doc/html/rfc5545)</sup>。

完整的重复实例集合即重复集合，由初始 DTSTART 连同 RRULE、RDATE 和 EXDATE 属性生成；DTSTART 定义第一个实例，其值应与规则同步，因为不匹配的组合会产生未定义的重复集合<sup>[4](https://datatracker.ietf.org/doc/html/rfc5545)</sup>。会产生无效日期（如 2 月 30 日）或不存在的本地时间（如时钟拨快那天的凌晨 1:30）的规则，必须忽略这些实例，且它们不计入 COUNT 限制<sup>[4](https://datatracker.ietf.org/doc/html/rfc5545)</sup>。

RFC 7529（2015）通过 RSCALE 元素扩展了 RRULE，使重复模式可以用非公历日历系统表达，日历系统定义取自 Unicode 联盟的通用语言环境数据存储库。对象中的日期和时间仍为公历；重复模式本身在所选日历系统中求值，SKIP 元素控制如何处理缺失的实例，例如非闰年中的 2 月 29 日周年纪念<sup>[9](https://datatracker.ietf.org/doc/html/rfc7529)</sup>。

## 实际使用

iCalendar 文件是日历交换的通用媒介。macOS 上的 Apple 日历应用将日历事件导出为 `.ics` 文件，将所有日历一次性导出为 `.icbu` 归档，并通过导入 `.ics` 文件在设备之间传输事件或将事件导入 iCloud<sup>[10](https://support.apple.com/guide/calendar/import-or-export-calendars-icl1023/mac)</sup>。Google Calendar 导入 `.ics` 和 `.csv` 文件，并将日历导出为 `.ics`<sup>[11](https://support.google.com/calendar/answer/37118?hl=en-7)</sup>。Outlook 可以从 `.ics` 文件导入事件，或在线订阅 iCal 日历并接收自动更新，还可以从支持该格式的程序（如 Apple iCal、Google Calendar 和 Mozilla Lightning）导入日历<sup>[12](https://support.microsoft.com/en-us/outlook/import-or-subscribe-to-a-calendar-in-outlook-com-or-outlook-on-the-web)</sup>。

厂商文档区分了两种使用模式。导入 `.ics` 文件会在导入时生成事件的静态快照，源数据变化时不会刷新，适合潮汐表这类稳定数据。订阅日历 URL 则连接日历，使更新自动传播，适合学校课程表这类频繁变化的数据；在 Outlook 网页版中，此类更新可能需要超过 24 小时，尽管它们应大约每隔几小时发生一次<sup>[12](https://support.microsoft.com/en-us/outlook/import-or-subscribe-to-a-calendar-in-outlook-com-or-outlook-on-the-web)</sup>。

除文件交换外，iCalendar 还是围绕它构建的日程安排与访问协议所承载的数据格式：iTIP（RFC 5546）定义会议请求和回复等日程安排操作，iMIP 将这些操作绑定到电子邮件，CalDAV（RFC 4791）扩展 WebDAV 使服务器能够存储和共享 iCalendar 资源；CalDAV 服务器必须支持以 iCalendar 作为日历对象资源的媒体类型<sup>[6](https://www.rfc-editor.org/info/rfc4791/)</sup>。Microsoft 记录了其 Outlook 实现对 iCalendar、iTIP 和 iMIP 的支持程度，包括产品与规范不同或扩展规范的方面<sup>[13](https://learn.microsoft.com/en-us/openspecs/exchange_standards/ms-stanoical/)</sup>。

## 局限与替代方案

JSCalendar 规范（RFC 8984，2021）由 Fastmail 的 N. Jenkins 和 R. Stepanek 撰写，记录了围绕 iCalendar 积累的实现问题：它为本地时间、UTC 和日期定义了多种格式；要求在单个日历组件内包含自定义时区定义；其重复规则定义含糊，即使在经验丰富的日历开发者之间也产生了不同解释；其以 CRLF 终止的字符串、行续接和解析器差异导致互操作性问题<sup>[7](https://www.rfc-editor.org/rfc/rfc8984.html)</sup>。JSCalendar 定义了一种与 iCalendar 大体兼容但并非直接映射的 JSON 数据模型（不同于早期的 jCal 格式 RFC 7265），旨在成为这一广泛部署格式的替代方案，并随时间推移成为其继任者<sup>[7](https://www.rfc-editor.org/rfc/rfc8984.html)</sup>。

该格式的灵活性也带来安全层面的问题。由于 `.ics` 文件为互操作性而构建，事件标题、描述或组织者字段可以携带富内容穿越 Outlook、Google Calendar 和 Apple Calendar，这使得日历文件难以用一致的方式进行大规模检查；安全指南将日历文件视同传统附件，要求检查元数据字段、嵌入链接与附件、HTML 渲染内容以及二维码<sup>[14](https://www.techradar.com/pro/security/it-is-significant-and-its-something-many-organisations-havent-accounted-for-the-phishing-threats-hiding-in-your-calendar-invites)</sup>。RFC 9074 为提醒增加了相关警示：未被适当监控的 VALARM 可能干扰用户或泄露个人信息，接近提醒可能泄露用户位置，因此接受第三方 iCalendar 数据的客户端应考虑在存储前移除 VALARM 组件<sup>[15](https://www.rfc-editor.org/info/rfc9074/)</sup>。

## References

1. [RFC 5545: Internet Calendaring and Scheduling Core Object Specification (iCalendar), RFC Editor](https://www.rfc-editor.org/info/rfc5545/)
2. [RFC 2445: Internet Calendaring and Scheduling Core Object Specification (iCalendar), RFC Editor](https://www.rfc-editor.org/info/rfc2445/)
3. [The iCalendar Standard, iCalendar.org](https://icalendar.org/the-icalendar-standard-2.html)
4. [RFC 5545 full text, IETF Datatracker](https://datatracker.ietf.org/doc/html/rfc5545)
5. [iCalendar Element Registries, IANA](https://www.iana.org/assignments/icalendar)
6. [RFC 4791: Calendaring Extensions to WebDAV (CalDAV), RFC Editor](https://www.rfc-editor.org/info/rfc4791/)
7. [RFC 8984: JSCalendar: A JSON Representation of Calendar Data, RFC Editor](https://www.rfc-editor.org/rfc/rfc8984.html)
8. [RFC 5545 document history, IETF Datatracker](https://datatracker.ietf.org/doc/rfc5545/)
9. [RFC 7529: Non-Gregorian Recurrence Rules in iCalendar, IETF Datatracker](https://datatracker.ietf.org/doc/html/rfc7529)
10. [Import or export calendars on Mac, Apple Support](https://support.apple.com/guide/calendar/import-or-export-calendars-icl1023/mac)
11. [Import events to Google Calendar, Google Calendar Help](https://support.google.com/calendar/answer/37118?hl=en-7)
12. [Import or subscribe to a calendar in Outlook.com or Outlook on the web, Microsoft Support](https://support.microsoft.com/en-us/outlook/import-or-subscribe-to-a-calendar-in-outlook-com-or-outlook-on-the-web)
13. [MS-STANOICAL: Outlook iCalendar Standards Support Version 2, Microsoft Learn](https://learn.microsoft.com/en-us/openspecs/exchange_standards/ms-stanoical/)
14. [The phishing threats hiding in your calendar invites, TechRadar](https://www.techradar.com/pro/security/it-is-significant-and-its-something-many-organisations-havent-accounted-for-the-phishing-threats-hiding-in-your-calendar-invites)
15. [RFC 9074: "VALARM" Extensions for iCalendar, RFC Editor](https://www.rfc-editor.org/info/rfc9074/)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 30, 2026; Oct 15, 2026 · Edited: Sep 30, 2026; Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 物质世界与数学 › 测量与时间 › 历法 › Calendars as artifacts, products, and software › Calendar data standards and interoperability

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/icalendar

English original: https://www.edgepedia.org/icalendar
