Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calendar: Initial support for iCalendar format #24695

Merged

Conversation

alec3660
Copy link
Contributor

This PR adds basic support for loading iCalendar (.ics) files and parsing VEVENT properties that are currently supported by Calendar Events: summary, start and end.

@github-actions github-actions bot added the 👀 pr-needs-review PR needs review from a maintainer or community member label Jul 12, 2024
Copy link
Contributor

@nico nico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

Userland/Applications/Calendar/EventManager.cpp Outdated Show resolved Hide resolved
{
Event event;
Vector<Event> events;
ICalendarParserState state = ICalendarParserState::Idle;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Maybe it'd be nice to move ical parsing out into a separate ICalParser class? Doesn't have to be in this PR though.

Userland/Applications/Calendar/EventManager.cpp Outdated Show resolved Hide resolved
@@ -97,14 +97,82 @@ ErrorOr<Vector<Event>> EventManager::deserialize_events(JsonArray const& json)
return result;
}

Core::DateTime EventManager::format_icalendar_vevent_datetime(String const& parameter)
{
auto invalid_datetime = Core::DateTime::create(0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's nice to add a few spec comments, like e.g.

    // 4.3.4 Date
    //   date               = date-value
    //   
    //   date-value         = date-fullyear date-month date-mday
    //   date-fullyear      = 4DIGIT
    //   date-month         = 2DIGIT        ;01-12
    //   date-mday          = 2DIGIT        ;01-28, 01-29, 01-30, 01-31
    //                                      ;based on month/year

    // 4.3.5   Date-Time
    //      date-time  = date "T" time ;As specified in the date and time
    //                                ;value definitions

    // 4.3.12 Time
    // time               = time-hour time-minute time-second [time-utc]
    // time-hour          = 2DIGIT        ;00-23
    // time-minute        = 2DIGIT        ;00-59
    // time-second        = 2DIGIT        ;00-60
    // ;The "60" value is used to account for "leap" seconds.
    // time-utc   = "Z"

…possibly interleaved with the code. We try to make code look a lot like the specs the code implement. (See e.g. GIFWriter.cpp or any file in LibJS for examples.)

4.3.5 mentions three forms (local time, utc, and explicit timezone). Supporting the first two seems pretty easy, might as well do that, and put in an explicit comment saying the third form isn't supported yet.

@alec3660 alec3660 force-pushed the calendar-initial-support-for-icalendar-format branch from b68a827 to eb6981e Compare July 12, 2024 16:06
@nico nico added ⏳ pr-waiting-for-author PR is blocked by feedback / code changes from the author and removed 👀 pr-needs-review PR needs review from a maintainer or community member labels Jul 12, 2024
This PR adds basic support for loading iCalendar (.ics) files and
parsing VEVENT properties that are currently supported by Calendar
Events: summary, start and end.
@alec3660 alec3660 force-pushed the calendar-initial-support-for-icalendar-format branch from eb6981e to 271478a Compare July 20, 2024 19:23
@github-actions github-actions bot added 👀 pr-needs-review PR needs review from a maintainer or community member and removed ⏳ pr-waiting-for-author PR is blocked by feedback / code changes from the author labels Jul 20, 2024
@nico nico merged commit 09d7a45 into SerenityOS:master Jul 21, 2024
11 checks passed
@alec3660 alec3660 deleted the calendar-initial-support-for-icalendar-format branch July 21, 2024 17:27
@github-actions github-actions bot removed the 👀 pr-needs-review PR needs review from a maintainer or community member label Jul 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants