justinwongcn/moon-ical/ical/model does not have a README file
pub struct Event {
uid : String?
summary : String?
location : String?
description : String?
dtstart : IcalDateTime?
dtend : IcalDateTime?
rrule : String?
recurrence_id : IcalDateTime?
recurrence_range : String?
status : String?
exdates : Array[IcalDateTime]
} derive(Debug)pub struct IcalDateTime {
wall : PlainDateTime
utc_offset : Int?
zone_id : String
all_day : Bool
} derive(Eq, Debug)impl Show for IcalDateTimefn test_example() raise {
let roots = @model.parse_components([
"BEGIN:VCALENDAR", "BEGIN:VTIMEZONE", "TZID:MY-ZONE", "BEGIN:STANDARD", "TZOFFSETTO:+0930",
"END:STANDARD", "END:VTIMEZONE", "END:VCALENDAR",
])
let table = @model.build_zone_table(roots)
assert_eq(table.lookup("my-zone"), Some(9 * 3600 + 30 * 60))
}fn test_example() raise {
let roots = @model.parse_components([
"BEGIN:VCALENDAR", "BEGIN:VEVENT", "SUMMARY:Sync", "END:VEVENT", "END:VCALENDAR",
])
assert_eq(roots.length(), 1)
assert_eq(roots[0].children[0].properties[0].value, "Sync")
}fn test_example() raise {
let line = @text.parse_content_line(
"DTSTART;TZID=Asia/Shanghai:20260908T093000", 1,
)
let dt = @model.parse_date_time(line, @model.ZoneTable::builtin_common())
assert_eq(dt.utc_offset, Some(8 * 3600))
assert_eq(dt.to_string(), "2026-09-08T09:30:00+08:00")
}fn parse_date_time_value(raw : String, zones : ZoneTable, tzid? : String?, value_is_date? : Bool, line_no? : Int) -> IcalDateTime raisefn test_example() raise {
let events = @model.parse_events(
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nSUMMARY:Sync\r\nEND:VEVENT\r\nEND:VCALENDAR",
)
assert_eq(events.length(), 1)
assert_eq(events[0].summary, Some("Sync"))
}fn parse_utc_offset(text : String, line_no~ : Int, raw~ : String) -> Int raisefn test_example() raise {
assert_eq(
@model.parse_utc_offset("+0530", line_no=1, raw="+0530"),
5 * 3600 + 30 * 60,
)
assert_eq(
@model.parse_utc_offset("-0800", line_no=1, raw="-0800"),
-(8 * 3600),
)
}Install
Download zipiCalendar (RFC 5545) parsing, recurrence expansion, and a minimal CalDAV server in pure MoonBit
Dependencies