fmeringdal / nettu-scheduler

A self-hosted calendar and scheduler server.
MIT License
535 stars 27 forks source link

Replace week_start integer with an enum #27

Closed omid closed 3 years ago

omid commented 3 years ago

It's unknown what the number is, for example, what is 0? It's better to replace it with an enum, with weekdays.

For example:

WeekDay::Sat
...
omid commented 3 years ago

chrono package already has this, we need to use it and re-export the enum in the SDK: https://docs.rs/chrono/0.4.19/chrono/enum.Weekday.html

fmeringdal commented 3 years ago

Same as the rrule crate: https://docs.rs/rrule/0.5.9/rrule/enum.Weekday.html I dont remember the reason on top of my head why I chose to model the week start with a number, but I guess there is no good reason.

Another semi related thing is the recurrence attribute on CalendarEvent which should ideally be modelled as an rrule string which is well defined instead of a custom Recurrence struct. Google Calendar does this, but Outlook Calendar does not.

omid commented 3 years ago

Yes, I mean exactly the same. 👍🏼

For Recurrence you mean this? https://github.com/fmeringdal/nettu-scheduler/blob/398d2589db4a7258d3deff67f1368127b91fc6e0/scheduler/crates/domain/src/event.rs#L22

For the Rust SDK, I'm fine to use RRuleOptions. But a better solution can be an enum, to support either rrule string or RRuleOptions. wdyt?