Home · Links · Contact Us
Home arrow Forums
Home
Features
FAQ
Screen Shots
Modules
Themes
Demos
Documentation
Forums
Contact Us
Download
Purchase
Quotes

" ... I want to tell you that your thyme product is functional and valuable beyond words. I cannot imagine why any portal would be without it. It is the cornerstone of our new project ..."

" ... Thanks for such a complete project, its making my job much easier. ..."

" ... I have now deployed 4 different calendars and our users love them ... "

" ... Easy to install and use and a great look/design. ..."

" ... This has to be the easiest to use program I think I've had to deal with at all this year. ..."


  FAQFAQ    SearchSearch  RegisterRegister   Log inLog in 
All instances of an event?

 
Post new topic   Reply to topic     Forum Index -> Hacking Thyme
View previous topic :: View next topic  
Author Message
mriedesel



Joined: 25 Sep 2007
Posts: 4

PostPosted: Tue Sep 25, 2007 5:19 pm    Post subject: All instances of an event? Reply with quote

I'm attempting to get all instance of an event so I can process the dates and times and then produce a nice succinct description of the event (ie: Mon thru Fri, 5-6:30pm).

One problem is that I have a specific range of dates that I need to search. This date range generally spans about two weeks, and I need to get events that take place within that range as well as events that continue on past the range end date, such that an event that repeats every day for 3 months would still return a full listing of instances so I could shorten the data down into something manageable like "January 3rd thru March 5th".

So, my question, is there a way to acquire a full listing of instances for a specific event id? Or do I just have to parse the repeat/interval values and figure out the times from there?

Thanks Smile
Back to top
View user's profile Send private message
mriedesel



Joined: 25 Sep 2007
Posts: 4

PostPosted: Wed Sep 26, 2007 6:27 pm    Post subject: Reply with quote

Just to clarify, the method I use for getting an event list is to generate a list of dates that fall within my start and end search ranges, then loop through them and pass them to $cal->get_event_list('day'). I store the event IDs in a list and then remove all the duplicates IDs.

Now, if I could loop through the event IDs and get every event instance associated with each ID, then that would be wonderful.
Back to top
View user's profile Send private message
esoft_ian



Joined: 12 Sep 2005
Posts: 5275

PostPosted: Wed Sep 26, 2007 7:42 pm    Post subject: Reply with quote

Hi,

You could do something like this:

Code:
# arguments are end date, start date
$days = $cal->get_event_list("2007-10-10", "2007-09-26");

$event_instances = array();

foreach($days as $d) {
   foreach($d as $event) {
       $event_instances[$event['id']][] = $event['instance'];
   }
}


Then $event_instance may have (for example) the following structure:
Code:

Array
(
    [49745] => Array
        (
            [0] => 1190808000
            [1] => 1191412800
            [2] => 1192017600
        )

    [47922] => Array
        (
            [0] => 1190880000
            [1] => 1191484800
        )

    [49750] => Array
        (
            [0] => 1190986200
            [1] => 1191591000
        )

    [49661] => Array
        (
            [0] => 1191240000
        )

    [47889] => Array
        (
            [0] => 1191912300
        )

)


It will hold each instance for each event id returned.

Let me know if you have any questions / trouble at all.
Back to top
View user's profile Send private message Visit poster's website
mriedesel



Joined: 25 Sep 2007
Posts: 4

PostPosted: Wed Sep 26, 2007 7:54 pm    Post subject: Reply with quote

Thanks for the quick response Ian.

The method you described works fine and is very similar to what I'm doing now. Although there's still a small issue, here's a little scenario:

My search range is Jan-1 to Jan-7, there is an event that begins on Jan-5 and repeats every day for 1 week. If I get a list of events for Jan-1 through Jan-7, then that event will appear but only the first 3 instances (Jan 5,6,7).

After processing the instance dates into friendly readable form, I the result would be incorrect, stating that the event begins the 5th and ends the 7th. So I'm trying to get a full list of instances for a given event in order to search ahead and avoid missing any repeating days that don't all necessarily fall within my search range.

I hope that makes some sense.
Back to top
View user's profile Send private message
esoft_ian



Joined: 12 Sep 2005
Posts: 5275

PostPosted: Wed Sep 26, 2007 7:56 pm    Post subject: Reply with quote

Would it be accurate to say that you want to know when an event stops repeating rather than every instance?
Back to top
View user's profile Send private message Visit poster's website
mriedesel



Joined: 25 Sep 2007
Posts: 4

PostPosted: Wed Sep 26, 2007 8:00 pm    Post subject: Reply with quote

That would be sufficient, so long as I can determine the start/end times and days that the event occurs on. I tried poking around the repeater code but it's all Zendified, so here I am Smile
Back to top
View user's profile Send private message
esoft_ian



Joined: 12 Sep 2005
Posts: 5275

PostPosted: Wed Sep 26, 2007 8:04 pm    Post subject: Reply with quote

$event->end should hold the event's end date. You should not need the repeater for that. If it is null or 0, then it does not have an end date set.

Let me know if this doesn't give you what you need.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Hacking Thyme All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
© 2005 eXtrovert software unless otherwise noted. All rights reserved.
Portions © 2004 Ben Brown. All rights reserved.
Trademarks are property of their respective owners.