# ohos-ical4j **Repository Path**: cbbgs/ohos-ical4j ## Basic Information - **Project Name**: ohos-ical4j - **Description**: No description available - **Primary Language**: Unknown - **License**: BSD-3-Clause - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-01-07 - **Last Updated**: 2026-01-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ohos_ical4j ## 简介 ohos_ical4j是一个基于OpenHarmonyOS的iCalendar (iCal) 解析库,用于处理日历数据。该项目提供了完整的iCalendar组件的创建、解析和操作功能,包括事件(VEvent)、提醒(VAlarm)、时区(VTimeZone)、待办事项(VToDo)、日记(VJournal)等多种日历组件的支持。 ## 下载安装 ```typescript ohpm install @ohos/ical4j ``` ## 使用说明 ### 基本使用 1. 导入所需的组件类 2. 创建Calendar实例 3. 添加日历组件(如VEvent, VAlarm等) 4. 使用提供的API进行操作和管理 ### 示例代码 ```typescript import { Calendar, VEvent, GenericProperty } from '@ohos/ical4j/Index'; // 创建日历 const calendar = new Calendar(); // 创建事件 const event = new VEvent(); event.setUid('unique-id@example.com'); event.setSummary('测试事件'); event.addProperty(new GenericProperty('DTSTART', '20230101T100000')); // 添加事件到日历 calendar.addComponent(event); // 验证日历 const validationResult = calendar.validate(); console.log(`日历验证结果: ${validationResult.isValid()}`); ``` ## 接口说明 ### 主要类 #### Calendar - `addComponent(component)`: 添加日历组件 - `getComponents()`: 获取所有组件 - `validate()`: 验证日历数据 - `copy()`: 复制日历 - `merge(otherCalendar)`: 合并另一个日历 #### VEvent - `setUid(uid)`: 设置唯一标识符 - `getUid()`: 获取唯一标识符 - `setSummary(summary)`: 设置摘要 - `getSummary()`: 获取摘要 - `setDescription(description)`: 设置描述 - `getDescription()`: 获取描述 - `setLocation(location)`: 设置位置 - `getLocation()`: 获取位置 - `setStartDate(date)`: 设置开始日期 - `getStartDate()`: 获取开始日期 - `setEndDate(date)`: 设置结束日期 - `getEndDate()`: 获取结束日期 #### VAlarm - `setAction(action)`: 设置动作 - `getAction()`: 获取动作 - `setTrigger(trigger)`: 设置触发器 - `getTrigger()`: 获取触发器 - `setRepeat(repeat)`: 设置重复次数 - `getRepeat()`: 获取重复次数 - `setDuration(duration)`: 设置持续时间 - `getDuration()`: 获取持续时间 #### VTimeZone - `setTzid(tzid)`: 设置时区ID - `getTimeZoneId()`: 获取时区ID - `setLastModified(date)`: 设置最后修改时间 - `getLastModified()`: 获取最后修改时间 - `addStandardComponent(comp)`: 添加标准组件 - `addDaylightComponent(comp)`: 添加夏令时组件 #### VToDo - `setUid(uid)`: 设置唯一标识符 - `getUid()`: 获取唯一标识符 - `setSummary(summary)`: 设置摘要 - `getSummary()`: 获取摘要 - `setDescription(description)`: 设置描述 - `getDescription()`: 获取描述 - `setLocation(location)`: 设置位置 - `getLocation()`: 获取位置 - `setPriority(priority)`: 设置优先级 - `getPriority()`: 获取优先级 - `setStatus(status)`: 设置状态 - `getStatus()`: 获取状态 - `setPercentComplete(percent)`: 设置完成百分比 - `getPercentComplete()`: 获取完成百分比 ### 属性类 - `GenericProperty`: 通用属性类,支持各种属性类型 - `Uid`: 唯一标识符属性 - `DtStart`: 开始日期时间属性 - `DtEnd`: 结束日期时间属性 - `Summary`: 摘要属性 - `Description`: 描述属性 - `Location`: 位置属性 - `DtStamp`: 时间戳属性 - `Created`: 创建时间属性 - `LastModified`: 最后修改时间属性 - `Sequence`: 序列号属性 - `Status`: 状态属性 - `Transp`: 透明度属性 - `Url`: URL属性 - `Uid`: UID属性 - `Rrule`: 重复规则属性 ## 目录结构 ``` /ohos_ical4j ├── entry/ # 示例代码 ├── library/ # 核心库模块 │ ├── src/ │ │ └── main/ │ │ └── ets/ │ │ ├── components/ # 组件实现 │ │ ├── model/ # 数据模型 │ │ ├── parser/ # 解析器 │ │ ├── properties/ # 属性类 │ │ ├── serializer/ # 序列化器 │ │ ├── utils/ # 工具类 │ │ └── validators/ # 验证器 ├── README.md # Readme ├── README_zh.md # Readme ``` ## 贡献代码 使用过程中发现任何问题都可以提 [Issue]() ,当然,也非常欢迎发 [PR]() 共建。 ## 开源协议 本项目采用 Apache License 2.0 许可证。详情请参见 [LICENSE.txt](./LICENSE) 文件。