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

Improve working with RRULE #171

Open
yordis opened this issue May 10, 2021 · 6 comments
Open

Improve working with RRULE #171

yordis opened this issue May 10, 2021 · 6 comments

Comments

@yordis
Copy link
Contributor

yordis commented May 10, 2021

Hey folks, thanks a lot for such an amazing package, I am currently using it only for the RRULE part of it, which for that I love what you did here: https://hexdocs.pm/excal/Excal.Recurrence.Stream.html#content it is super clean and easy to follow when it comes to the RRULE part of it.

I wonder if you can bring such API and functionality at the RRULE level into this package. Or write some documentation about suggesting what are the differences and when to use what, since you maintain both of them so would helpful for folks like me that are not that educated about icalendar spec and the topic in general.

Thanks in advance.

@yordis
Copy link
Contributor Author

yordis commented May 10, 2021

Also, I need some way to ask questions to the RRULE such as:

// (I know is ugly it suppose to go away 😄 )

// from https://github.com/teambition/rrule-go
rOption, err := rrule.StrToROption(v)

	if err != nil {
		return nil, err
	}

if rOption.Freq != rrule.MONTHLY || rOption.Interval != 1 || len(rOption.Bymonthday) != 1 || rOption.Bymonthday[0] != 1 {
		return nil, errInvalidRRrule
	}

Since we have some temporary rules

So maybe create some object for the RRULE: part of it

@yordis
Copy link
Contributor Author

yordis commented May 10, 2021

Here is an example of the data structure (I removed the dtstart since technically doesn't belong to rrule: part, but it is adjacent to it, please correct me if I am wrong)

type Frequency int

// Constants
const (
	YEARLY Frequency = iota
	MONTHLY
	WEEKLY
	DAILY
	HOURLY
	MINUTELY
	SECONDLY
)

type RRule struct {
	Freq       Frequency
	Interval   int
	Wkst       Weekday
	Count      int
	Until      time.Time
	Bysetpos   []int
	Bymonth    []int
	Bymonthday []int
	Byyearday  []int
	Byweekno   []int
	Byweekday  []Weekday
	Byhour     []int
	Byminute   []int
	Bysecond   []int
	Byeaster   []int
}

@yordis
Copy link
Contributor Author

yordis commented May 10, 2021

Here is another good example: https://hexdocs.pm/vobject/ICalendar.RRULE.html

@doughsay
Copy link
Collaborator

You say you like the way excal works for streaming occurrences from rrules, so I'm curious, why do you not just want to use excal itself? Is it the Elixir interface of cocktail that you like as opposed to the bare-bones icalendar syntax required by excal?

I'm asking because I feel that excal is a better way of getting actual iCalendar spec compatibility and much better performance. Coktail was my first attempt at this problem, but has several problems as you may be finding out. So I'm wondering if maybe the better effort should be spent bringing excal up to what you want it to be?

@yordis
Copy link
Contributor Author

yordis commented May 12, 2021

@doughsay take everything keeping in mind that I don't have much experience in the topic.

so I'm curious, why do you not just want to use excal itself?

Because I need to ask some questions to the RRULE object, this ugly part:

if rOption.Freq != rrule.MONTHLY || rOption.Interval != 1 || len(rOption.Bymonthday) != 1 || rOption.Bymonthday[0] != 1 {
		return nil, errInvalidRRrule
	}

So excal is amazing but doesn't have any intermediate step, which thinking about it I am not even sure if cocktail allows me to do this easier either, I pushed it aside for now since the RRule structure in cocktail is kind of weird to me.

This is temporary btw.

And second, I thought I am not gonna act that paranoid, a simple NIF mistake could mean the entire VM is down, which raises the question, do I really want the performance or the usage of a NIF for this?

I don't know the NIF used in the package that well, but that is not the main reason at all.

(Also, I thought in using https://github.com/dashbitco/nimble_parsec in order to parse things but I honestly don't have time at the moment)

@yordis
Copy link
Contributor Author

yordis commented May 12, 2021

Second post about the topic in general,

Making excal to be the parsers, and the iterator would be the ideal scenario, I rarely use much of the cocktail API other than, give me the next transfer date (fintech lingo), so I don't need the extra stuff.

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

No branches or pull requests

2 participants