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

Document the features of When #2

Closed
tplaner opened this issue Oct 31, 2010 · 9 comments
Closed

Document the features of When #2

tplaner opened this issue Oct 31, 2010 · 9 comments
Labels

Comments

@tplaner
Copy link
Owner

tplaner commented Oct 31, 2010

Create documentation of the current capabilities and limitations.

@jamesmehorter
Copy link

I would like to see a more categorized and readable documentation for this library. It's really quite amazing - just took a good deal of digging to piece together what I needed. Can you put together just a list of all methods and uses in an easy to read format?

@tplaner
Copy link
Owner Author

tplaner commented Nov 22, 2010

Documentation is definitely in the works, been very busy the past few weeks. If there is anything specific you have questions about, feel free to send me a message.

@otherjohn
Copy link

Hi, this looks like it's exactly what I was looking for!

My question is, how would I use this to list "upcoming" events of a particular date range from DB entries?
How would you suggest I enter events into a DB to work with this library?
Thanks!

@jamesmehorter
Copy link

Hi Gospel Labs.. it sounds like you may not even need When to do what you're trying to do.

I would store the date as a php timestamp in your db, for instance using php's time() function or the DateTime object to generate your timestamp. http://php.net/manual/en/function.time.php The timestamp will look something like 1324476804 (just an int), which you can perform basic math on to pull only upcoming events from your db, i.e. SELECT * FROM events_table WHERE event_date > " . time() . "

Hope that helps!

@otherjohn
Copy link

thanks for the quick reply.
Basically, I am building an events manager in which users can add recurring events. I am trying to find a way to store the recurring events efficiently in the DB without filling the DB with an infinite occurrence of an event.
My thought was to store a event "Rule" which you could pull events from. I might be way off here since I am no expert, so I am looking for better ways.

@jamesmehorter
Copy link

Hey again Gospel Labs. I did something similar and just stored the initial event date in the db dnd for the recurrence 'rule' I stored a serialized php array in the db which just had a field for the recurrence interval (weekly, monthly, yearly) and the number of times the event occurred (1, 2, 3, 4,...) So my array looked like: Array('interval' => 'weekly', 'occurrence' => 4)

Then I would pull that event record from the db, and with When just plugged in the event start date, the interval, and the occurrence which generated an array of all the future event timestamps that I used to output to the end-user.

@otherjohn
Copy link

Awesome, I will try to sort that out and put it to code. Thanks!

@otherjohn
Copy link

quick question: would I be able to pull a list of events using this method (like all upcoming events this week, or the next 10 upcoming events)

@jamesmehorter
Copy link

That's the one downside I've found to storing only the initial timestamp, is that you can't just do a sql query to pull the future events. You would have to pull the initial event, generate the recurrences, and with php only output the future events.

I was creating a calendar, so I wanted ALL the events, not just upcoming. So I would pull all the events, generate their recurrences, and output them. You could go either route, though sounds like it may be better for you to store all the recurrences instead of just the initial one.

zanbaldwin referenced this issue in zanbaldwin/when Oct 25, 2013
Add functionality to offset the generated occurrences by a specific amount.
@tplaner tplaner closed this as completed Aug 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants