Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

Search

 
Advanced search

8043 Posts in 1856 Topics- by 2099 Members - Latest Member: roi
Calendar Script CommunityCustomizationCustomizing CalendarScript (Moderators: scott, DanO, Marty)list last two hours + next 8 hours
Pages: [1]   Go Down
Print
Author Topic: list last two hours + next 8 hours  (Read 525 times)
0 Members and 1 Guest are viewing this topic.
stevea
Guest
« on: September 08, 2003, 01:54:00 PM »

I am attempting to modify the template to last the last two hours and the next several (Cool hours. I tried to change the days from "7D" to "8H" without success...

Any suggestions?

Thanks

Logged
stevea
Guest
« Reply #1 on: September 08, 2003, 03:50:00 PM »

I'm playing around with this and it looks like "8h" will list 8 hours from beginning of day instead of the next 8 hours.  

Ideally I'd like to start a few hours previous to current time too.

Thanks,
Steve

Logged
stevea
Guest
« Reply #2 on: September 08, 2003, 04:36:00 PM »

still playing around...without success.

I lifted some code from another message and tried adding it below <%FOREACH EVENTLIST%> in the template file...

<% next if ($HOUR < (SCHEDULE FIELD(start_hh)-2); %>

but it failed with this...

Can't locate object method "SCHEDULE" via package "FIELD" (perhaps you forgot to load "FIELD"?) at (eval 1) line 54.
----------------

I will check back in the moring for any replies.

Thanks!
Steve

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #3 on: September 08, 2003, 07:57:00 PM »

I not really sure what you're talking about but this line:

<% next if ($HOUR < (SCHEDULE FIELD(start_hh)-2); %>

would have to be something like:

<% next if ($HOUR < $EVENT->{'schedule'}->{'start_hh)-2); %>

(whatever that line is suppose to go).

Dan O.

------------------

Logged
stevea
Guest
« Reply #4 on: September 09, 2003, 01:02:00 AM »

thanks dan,  I was trying a few different things. My ramblings probably confused things.

I am attempting to modify the template to list the previous two hours of events and the next eight hours of events. I tried to change the command line to "8H" but it appears to start from midnight instead of current time.

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #5 on: September 09, 2003, 01:03:00 PM »

** I am attempting to modify the template **

Which template?

Dan O.

------------------

Logged
stevea
Guest
« Reply #6 on: September 09, 2003, 01:25:00 PM »

I'm fairly new to calendarscript, so I apologize for fumbling along.  I'll cut/paste the template (as is, not working correctly) below.

My goal is list events beginning two hours prior to the current time, and up to x hours after current time.

Thanks for your help.
Steve

----------------- thetemplate.htm below: -----------

<!--#include file="preferences.pl"-->
<style type="text/css">
<!--
body { font-family: Veranda, Arial, Helvetica, sans-serif; font-size: 11px; color: #003399}
-->
</style>
<%
&getEvents( {'duration'=>$in{duration}} );
$DAY = $Grid->{'grid'}->

  • ->
  • ;
    $EVENTS = $DAY->{events};
    $total_events=0;
    %>

    <DL>
    <%FOREACH EVENTLIST%>
    <!-- ************************************************ -->
    <!-- ************************************************ -->
    <!-- ************************************************ -->
    <!-- STEVE ADDED BELOW TO attempt to SKIP UP TO CURRENT TIME -->
    <% next if ($HOUR < $EVENT->{'schedule'}-{start_hh}); %>
    =
       <%IF EVENTS EXIST%>
       <%$total_events++;%>
       <DT><B><%=$DAY->{dayname}%>, <%=$DAY->{monthname}%> <%=$DAY->{dd}%></B>

    <BR>
          <%FOREACH EVENT%>
             <% if ($_SHOW_GRID_EVENT_BULLET) {%>•<%}%>
             <% if ($_SHOW_EVENT_TIMES eq "ALL" | | $_SHOW_EVENT_TIMES eq "START") { %>
                <% if ($EVENT->{'schedule'}->{'start_time'}) { %><%= SCHEDULE FIELD(start_time) %><% } %>
             <% } %>
             <% if ($_SHOW_EVENT_TIMES eq "ALL") { %>
                <% if ($EVENT->{'schedule'}->{'end_time'}) { %>-<%= SCHEDULE FIELD(end_time) %><% } %>
             <% } %>
             <% if (($_SHOW_EVENT_TIMES eq "ALL" | | $_SHOW_EVENT_TIMES eq "START") && ($EVENT->{'schedule'}->{'start_time'})) { %> : <% } %>
             <a href="<%= $EVENT->{'details'}->{'showhome'} %>">
             <b><%= $EVENT->{'details'}->{'title'} %></b>
             </a> -
             <%= $EVENT->{'details'}->{'description'} %>
             <a href="<%= $EVENT->{'details'}->{'webcast'} %>">
             (listen)
             </a>
    <BR>
          <%/FOREACH%>
       <%/IF%>
    <%/FOREACH%>
    </DL>
    <%unless($total_events){%>
    <CENTER><I><%= $_NO_EVENTS_LABEL %></I></CENTER>
    <% } %>
    <!--
    <A HREF="<%=$AdminConfig->get("calendar_url")%>?calendar=<%=$calendar_key%>" target="_top">View Calendar</A>

    -->

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #7 on: September 09, 2003, 02:52:00 PM »

** I tried to change the command line to "8H" but it appears to start from midnight instead of current time. **

If I'm not mistaken, all the events are dated using the first second of the particular day (GMT) they're scheduled for. All events scheduled on the same day would have the same UNIX time code in their schedule records.

** My goal is list events beginning two hours prior to the current time **

The line in your template likely causing the problem is
&getEvents( {'duration'=>$in{duration}} );
which will only get events for that duration from the current date forward.

It may be able to be change to get the whole previous day's events as well but I can't think of a way to get just the last 2 events of that previous day like you want.

BTW. I do not believe that "8H" is a valid parameter for that routine, I believe the number of days is the smallest increment it will accept.

Dan O.

[This message has been edited by DanO (edited September 09, 2003).]

Logged
stevea
Guest
« Reply #8 on: September 10, 2003, 12:18:00 PM »

Dano, thanks for helping.  I'm not actually trying to list the last two events prior to current time, just the last two hours worth of events (current time minus two hours)...

example.. current time is 1pm and I want to list 11am through Xpm (X=number of hours past current time, lets say 8 hours for now).

if the template I used isn't the best approach, I'm open to other suggestions  

Thanks again,
Steve

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #9 on: September 10, 2003, 05:14:00 PM »

** I do not believe that "8H" is a valid parameter for that routine, I believe the number of days is the smallest increment it will accept. **

 That however is incorrect.

It does look like the calendar is capable of retrieving specific hours of events but the attribute would have to be "8h" (note the lower case as it should be for any of the other variable names used there).

So if you could just pass a previous date/time at which to retrieve events starting from, it may be possible.

Alternately, it looks like it might also accept just a start and end time in Unix format in which case you may be able to do some math to come up with appropriate values to reference. Eg.

&getEvents( {'start'=>time-7200}, 'end'=>time+28800}} ); # 7200 = 2 hours, 28800 = 8 hours

This is untested though.

Dan O.


[This message has been edited by DanO (edited September 10, 2003).]

Logged
stevea
Guest
« Reply #10 on: September 11, 2003, 01:25:00 PM »

Thanks again DanO...

I'll keep searching for a template to list the current time minus 2 hours and plus 8 hours.  If you/anyone has a lead, it's appreciated.  

... keep in mind that I'm brand new to this and basically clueless  to this code.

Logged
stevea
Guest
« Reply #11 on: September 15, 2003, 11:47:00 AM »

Maybe someone is browsing through with other suggestions for a template / command line (combo of both) for me (beginner of calendarscript) to try?

my goal...  to list the past two hours worth of events, if any, and the next x (x=hours past current time) worth of events. For this example, lets say the next 8 hours worth of events.

Thanks!
Steve

Logged
Pages: [1]   Go Up
Print
Jump to: