In 2.6 and previous when entering Multi Day All Day Events I simply left the time empty on both days and the all day event was correctly recognized. In the current 2.7 and dev versions these events are not recognized as All Day events and the time shows as 12:00am after each day. The attached screen shots are against a fresh install. I'm running PHP 5.2.13 and I've gone through the troubleshooting steps.

Comments

zoltán balogh’s picture

Fix it as soon as possible, please.

lukebrooker’s picture

Version: 6.x-2.x-dev » 6.x-2.7

I am having the same problem.

Morn’s picture

Same Problem (Date 6.27 and Drupal Version 6.20)

penguin25’s picture

Title: Support for Multi Day All Day Events » 'All day' events displaying a time instead of 'All day'

I've been looking into something similar to this on my site since upgrading to 6.x-2.7. I don't have any multi-day events, but I do have events running from 00:00 to 23:59 that were previously being displayed as "All day", but are now shown as 00:00 - 23:59.

For me, the problem occurs in a View that is displaying a date/time with a different granularity to the granularity of the underlying field. I haven't got a full solution yet, but it looks like it's related to the addition of the new "date_is_all_day()" function in date_api.module, and the subsequent changes to various other bits of code to use this function instead of trying to work out whether or not something is all day in an ad-hoc fashion.

In particular, if you look at the function theme_date_all_day() in date/date.theme in the old 6.x-2.6 release, you can see that it worked out whether something was all day or not using the granularity of the $format variable. But in 6.x-2.7, theme_date_all_day() calls date_field_all_day(), which in turn calls date_is_all_day(). If you follow this sequence of calls through, you can see that $format gets dropped, and the granularity is calculated from $field['granularity'].

On my site, the date fields have a granularity of seconds, but are displayed in a View with a granularity of minutes. So if:

  • the end time of an event is being stored in the datebase as 23:59:00, and not 23:59:59
  • the $format variable (now unused) was set up from the View's granularity to 'minute'
  • $field['granularity'] is set up from the field definition to be 'second'

then you can see why the behaviour has changed from 6.x-2.6 to 6.x-2.7. I think, although I haven't read the issue in detail, that it's similar to #447728: "All day" nodes are not detected as such because of the granularity of the Date field in the Calendar module.

Unfortunately I don't have time to work on this any more. I've come up with a workaround that is simply to explicity set $granularity to 'minute' at the start of date_is_all_day(), and ignore the value that is passed in. This works for me because my site always display dates with a granularity of minutes, but obviously it won't work for everyone.

I hope these comments can point somebody else in the direction of a proper fix.

fonant’s picture

FWIW I get this problem too.

gtaylor’s picture

+1 we have the same issue

kassissieh’s picture

Awkward, temporary workaround: modify the final else statement to remove 12:00am in multi-day, all-day date displays (add to your template.php file).

// override "all day" calculation to suppress display of "12:00am"
function phptemplate_date_all_day($field, $which, $date1, $date2, $format, $node, $view = NULL) {

  if (empty($date1) || !is_object($date1) || $format == 'format_interval') {
    return;
  }
  if (empty($date2)) {
    $date2 = $date1;
  }
  
  if (!date_has_time($field['granularity'])) {
    $format = date_limit_format($format, array('year', 'month', 'day'));
    return date_format_date($$which, 'custom', $format);
  }
  
  if ($all_day = date_field_all_day($field, $date1, $date2)) {
    $format = date_limit_format($format, array('year', 'month', 'day'));
    return trim(date_format_date($$which, 'custom', $format) .' '. theme('date_all_day_label'));
  }
  else {
    // only this else statement is modified from the original function
    $toreturn = date_format_date($$which, 'custom', $format);
    $toreturn = str_replace(' - 12:00am','',$toreturn);
    return $toreturn;
  }
}
Morn’s picture

Nice Quick & Dirty, I applied it directly to date.theme (in date/date) using "- 00:00" because of 24 hours format

maddentim’s picture

Status: Active » Needs review
StatusFileSize
new687 bytes

The problem is an if condition in theme_date_all_day() that uses = (for assigning value) instead of ==(for comparison). Here is a patch that solves it on mine. Please apply and test. Should work on 2.7 release. computers are so literal.

maddentim’s picture

Assigned: Unassigned » maddentim
penguin25’s picture

I don't agree with the patch in comment 9. The line mentioned there is testing the return value of date_field_all_day(), and simultaneously assigning the result into $all_day. This is the first time that $all_day has been written to, so using it in a comparison instead can't be right.

guusbosman’s picture

+1 subscribe

ron collins’s picture

subscribe

wotaber’s picture

subscribe

dperdue’s picture

Version: 6.x-2.7 » 6.x-2.x-dev
StatusFileSize
new446 bytes

In date_api.module on line 2679 inside the function date_is_all_day there's this block of code:

  if (empty($date1) || empty($date2) || $date1 != $date2) {
    return FALSE;
  }

which automatically makes events with different start and end dates not be recognized as All Day events. If you remove the last assertion in if statement then it looks like this:

  if (empty($date1) || empty($date2)) {
    return FALSE;
  }

and it works for All Day, Multi-Day events. I'm not sure the reasons why that assertion was there in the first place.

I've attached a patch.

ron collins’s picture

the patch failed for me on 2.7 but i made the change manually and i now see "all day" as expected. i can't vouch for why the removed code was there in the first place. Thanks!

dperdue’s picture

The patch is against the current dev release.

niek_kloots’s picture

Status: Fixed » Needs review

Date 6.x-2.7
Calendar 6.x-2.4
Views 6.x-2.12

After applying the patch #15 the time in a multi-day event 0:00 is replaced with 'All day'
example:
Monday, 18 April, 2011 (0:00) - Tuesday, 19 April, 2011 (0:00) - old view
Monday, 18 April, 2011 (All day) - Tuesday, 19 April, 2011 (All day) - new view

Thanks for the patch. This looks better.

maddentim’s picture

@penguin25 #11

Good point. Sorry not to have seen this in a bit. Got swamped.

However, it worked as I needed it to after I made the change.

Looking closely I see that, in the end, date_field_all_day() always returns either a TRUE or a FALSE and thereby could drive the if condition. While it is the first time $all_day is written to, it also seems to be the last as it is not used again in this function or returned so wouldn't it be better to just do?

if (date_field_all_day($field, $date1, $date2)) {

Seems like a waste of memory to assign $all_day to memory.

osopolar’s picture

The patch in #15 failed for 2.7, it's late and so I don't see why. But as #16 I've made the change manually and "(all day)" is back.

developer-x’s picture

Status: Needs review » Fixed

I've verified the change in #15. It's a good fix. I've committed the fix to 6.x-2.x and 7.x-2.x

Status: Needs review » Closed (fixed)

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

dperdue’s picture

StatusFileSize
new493 bytes

See next comment.

Another patch that applies against the 6.x-2.7 release for Drush Make purposes.

dperdue’s picture

StatusFileSize
new489 bytes

Nevermind above, this is a patch that will work with Drush Make against 6.x-2.7

marktheshark’s picture

Sorry for reviving this thread, but how do you make Date allow the storing of events without time-of-day in order to create all day events, when the granularity includes minutes?

I keep getting 'invalid date' and I'm unable to store the node...

modiphier’s picture

Version: 6.x-2.x-dev » 6.x-2.7
Component: Date CCK Field » Code
Assigned: maddentim » Unassigned

Hello,

I have made the change to date_api.module as listed in comment #15 but when I add an all day event it displays a default time of 7:00pm I have date 6.x-2.7 what am I missing why is a default time still appearing. Do I need to flush anything after making the change to the .module file.

Start: Monday, September 3, 2012 7:00 pm

Thanks,
Paul

modiphier’s picture

Version: 6.x-2.7 » 6.x-2.8
Priority: Normal » Major
Status: Closed (fixed) » Active

Just uploaded the date-6.x-2.8 and I am still getting a default time of 7:00pm for an all day event? Any ideas or fix for this yet??

Thanks,
Paul

arlinsandbulte’s picture

Status: Active » Closed (duplicate)

The patch in #24 of #1017216: custom date format without time shows "all day" should take care of this problem.
Please check that out and provide feedback if needed.

Thanks,