I would like something like fc-event-past to be added to events in the past. Then I can easily set them to fade (like Google Calendar).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

aspilicious’s picture

Assigned: Unassigned » aspilicious

Heard this before. Let's try it....

aspilicious’s picture

Ok we are going to fix this :).

In theme.inc we have

$entity->class
and

$date1 = $date['value']['local']['object'];
$date2 = $date['value2']['local']['object'];

We should add "fc-event-past" to entity->class if $date2 (== end date) < current date.
Probably there are date module functions for this. I'll ask Tim.

Sadly enough we can't do this in fullcalendar_fullcalendar_classes...

tim.plunkett’s picture

Status: Active » Needs review
FileSize
1.17 KB

See attached.

There's no real easy way to expose what this class name should be, or if it should even be added, but this is fine.

pjcdawkins’s picture

That patch works for me.

aspilicious’s picture

if we are going to do this I propose this code:

 $time_class = 'fc-event-now'
if(strtotime($end) < strtotime('now')) {
  $time_class = 'fc-event-past'
}
else if (strtotime($start) > strtotime('now') : 'fc-event-future') {
  $time_class = 'fc-event-future'
}
tim.plunkett’s picture

I don't agree. With this code, it will only happen if you refresh the page on the EXACT second the event ends, not if you're in the middle of the event.

If we really want to add a bunch more code, we can figure out if we're in the middle of the event or not...

aspilicious’s picture

Are you sure?

In the second test I use the start date of the event. So when you're in the middle it will choose 'fc-event-now'

tim.plunkett’s picture

Oh my brain/eyes skipped that part. Yeah I guess that's okay with me. Want to reroll?

aspilicious’s picture

Tomorow, need some sleep :)

pjcdawkins’s picture

Well I don't know if this is the right etiquette but while you were sleeping I made a patch. I need more practice than you do. It's based on, but not identical, to #5.

tim.plunkett’s picture

Status: Needs review » Needs work

I like the use of REQUEST_TIME, forgot about that.

+++ b/theme/theme.incundefined
@@ -245,6 +245,18 @@ function fullcalendar_prepare_events($view, $rows, $options) {
+          else if (strtotime($start) > REQUEST_TIME) {

should be elseif

Can you reroll again? More practice ;)

pjcdawkins’s picture

Status: Needs work » Needs review
FileSize
1.33 KB

Rerolled

pjcdawkins’s picture

We need to check for all day events.

aspilicious’s picture

What if I have an $all_day date in the past that will fail.

$all_day is an event that last one day (24 hours)

pjcdawkins’s picture

Oh good point! Something like...

  if (($all_day && strtotime($end) < strtotime('today 00:00:00'))
       || (!$all_day && strtotime($end) < REQUEST_TIME)) {
    $time_class = 'fc-event-past';
  }
  elseif (strtotime($start) > REQUEST_TIME) {
    $time_class = 'fc-event-future';
  }
aspilicious’s picture

do we cover all day events that are happening now? ;)

pjcdawkins’s picture

They'll be "now" by default, surely, because the start time will be < REQUEST_TIME and > midnight. I think it actually has to be:

          $time_class = 'fc-event-now';
          if (($all_day && strtotime($start) < strtotime('today 00:00:00'))
              || (!$all_day && strtotime($end) < REQUEST_TIME)) {
            $time_class = 'fc-event-past';
          }
          elseif (strtotime($start) > REQUEST_TIME) {
            $time_class = 'fc-event-future';
          }
aspilicious’s picture

If you reroll I'll test it. Tim has to decide if we want to add these extra classes and code...

pjcdawkins’s picture

Sure. There's another problem: events with no end date are assumed to have 0 duration, whereas the default duration should really be read from the FullCalendar settings... I think that should be dealt with in _fullcalendar_process_dates(), unless the Date module has a default duration setting somewhere that I've missed.

pjcdawkins’s picture

Status: Needs review » Needs work
FileSize
1.42 KB

The feature seemed simple when I opened the thread!... Marking needs work for #19, attaching a patch for other work up to #17.

tim.plunkett’s picture

+++ b/theme/theme.incundefined
@@ -245,6 +245,19 @@ function fullcalendar_prepare_events($view, $rows, $options) {
+          if (($all_day && strtotime($start) < strtotime('today 00:00:00'))

According to http://www.php.net/manual/en/datetime.formats.relative.php, it can just be strtotime('today').

+++ b/theme/theme.incundefined
@@ -245,6 +245,19 @@ function fullcalendar_prepare_events($view, $rows, $options) {
+              || (!$all_day && strtotime($end) < REQUEST_TIME)) {

I don't like wrapping code unless it's REALLY long, let's keep this on one line.

pjcdawkins’s picture

Status: Needs work » Needs review
FileSize
1.4 KB

OK, I've updated the patch. I haven't found a standard for giving events a default duration (where there is no end date specified), so I'm not sure how to proceed with #19.

tim.plunkett’s picture

By default, FullCalendar shows events with the same start/end as 2 hours long. That's configurable via the FullCalendar Options module.

Not sure that it really matters.

pjcdawkins’s picture

Status: Needs review » Reviewed & tested by the community

Well, I don't think it matters that the time classes should respect default durations, it only affects events without end times set, only shortly after they've started, and only for those actually using these classes for styling. And this whole issue is minor anyway. And I'm using the patch in #22 successfully, in production.

tim.plunkett’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Fixed

Sorry for the insane delays.
Committed, thanks!
http://drupalcode.org/project/fullcalendar.git/commit/bc205ca

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.