hello

when i print the date value like this :$node->field_date_event[0]['view'] i get an (All Day) printed behind it, but i don't want it ...
what can i do?

sometimes i have events with hours : minutes - sometimes not.
so my granularity is including hours : minutes, but i do not need them always.

thanks momper

Comments

momper’s picture

hello

do i something wrong?

thanks momper

KarenS’s picture

Status: Active » Fixed

It's a theme, you can override it to show nothing. The theme is called 'theme_date_all_day_label' and it is in date/date/date.theme.

Status: Fixed » Closed (fixed)

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

yakker’s picture

I'm not sure if I'm right about this or not (i'm not a coder), but I think theme_date_all_day() may be appending "all day" to ANY dates with:

1. NO 'to date' ('never')
2. Granularity < day (ie. hour, min, sec).

The conditional test seems to check whether or not there is granularity = to hour, min, or day, but also to see if there's a mincomp and maxcomp value. But in the switch statement, the mincomp and maxcomp values are automatically assigned because of the granularity. So there will always be mincomp and maxcomp when granularity is hour, minute or second.

With no "to date," the $mincomp and $maxcomp get created from $date1 and $date2, respectively, and both $date1 and $date2 have the same value.

But there doesn't seem to be a comparison check between date1 and date 2. If they're equal, it should default to the regular formatting, right? My apologies for any confusion if I'm wrong about any of this. :S

<?php /* taken from date.theme in the date module */

function theme_date_all_day($field, $which, $date1, $date2, $format, $node, $view = NULL) {
  if (empty($date1) || !is_object($date1) || $format == 'format_interval') {
    return;
  }
  if (empty($date2)) { /* This is checking if there is no 'to date, right? */
    $date2 = $date1;
  }
  $granularity = array_pop(date_format_order($format));
  if (empty($field['granularity'])) {
    $field['granularity'] = date_format_order($format);
  }
  $increment = $field['widget']['increment'];
  $max_seconds = array_pop(date_seconds('s', TRUE, $increment));
  $max_minutes = array_pop(date_minutes('i', TRUE, $increment));
  
  switch ($granularity) {
    case 'second':
      $min_comp = date_format($date1, 'H:i:s') == '00:00:00';
      $max_comp = date_format($date2, 'H:i:s') == '00:00:00' || date_format($date2, 'H:i:s') == '23:'. $max_minutes .':'. $max_seconds;
      break;
    case 'minute':
      $min_comp = date_format($date1, 'H:i') == '00:00';
      $max_comp = date_format($date2, 'H:i:s') == '00:00:00' || date_format($date2, 'H:i') == '23:'. $max_minutes;
      break;
    case 'hour':
      $min_comp = date_format($date1, 'H') == '00';
      $max_comp = date_format($date2, 'H:i:s') == '00:00:00' || date_format($date2, 'H') == '23';
      break;
    default:
      $min_comp = TRUE;
      $max_comp = FALSE;
  }
  
  // Time runs from midnight to the maximum time -- call it 'All day'.
/* A 'from date' with 4pm and Hour granularity with NO 'to date' will return true on this check, I think, which makes it an "all day" event when it shouldn't be one - it has no 'to date.'  Am I wrong about this??? */

  if (date_has_time($field['granularity']) && $min_comp && $max_comp) { 
    $format = date_limit_format($format, array('year', 'month', 'day'));
    return trim(date_format_date($$which, 'custom', $format) .' '. theme('date_all_day_label'));
  }
  // There is no time, use neither 'All day' nor time.
  elseif (!date_has_time($field['granularity'])) {
    $format = date_limit_format($format, array('year', 'month', 'day'));
    return date_format_date($$which, 'custom', $format);
  }
  // Normal formatting.
  else {
    return date_format_date($$which, 'custom', $format);
  }
}

?>
embirr’s picture

I can't confirm or deny what the code says, but if you set granularity in the Date field to "day," the "All day" label disappears.

Encarte’s picture

There is an example of how to do this on this message: http://drupal.org/node/386406#comment-1325736 (endorsed by KarenS here: http://drupal.org/node/386406#comment-1331578). Worked for me.

jerodfritz’s picture

When you added the Date field to your CCK type you selected the amount of granularity to use. By default Year, Month, Day and Hour is selected. Unselect hours and the (All Day) will disappear.

-Jerod

Anonymous’s picture

Just for those who wonder how to get ride of the (all day) and are lazy to go check the previously mentionned link, this, pasted in template.php in your theme, will remove every instance of it :


function [theme name]_date_all_day_label() {
  return '';
}

mikejonesok’s picture

Thanks for the tip!

bryanhidalgo’s picture

Thanks

wayne.gormont’s picture

Just what I was looking for! Thanks so much!

bardya’s picture

Simple but deadly! thanks

lfrey’s picture

Does it matter where you paste it? I tried this and the whole site broke - I got a white screen.
Thanks - all help greatly appreciated.
Lynne

bardya’s picture

You can paste it anywhere , i usually paste it at the end of the file. There may be something else that is causing this error. What you are seeing is the infamous drupal white screen of death which is covering the error. To see the specific error check out this post:

http://drupal.org/node/158043

Good Luck,

lucio.ferrari’s picture

Hi, I tried this fix. Since the theme I use is 'pixture reloaded' I added:

function pixture_reloaded_date_all_day_label() {
  return '';
}

but it doesn't seem to override theme_date_all_day_label()...

Am I doing something wrong? I'd like to avoid messing with date module's templates, since I'd prolly forget about any custom changes when upgrading.

Thanks in advance.

lucio.ferrari’s picture

Fixed.
Changed to

function phptemplate_date_all_day_label() {
  return t('&nbsp');
}

flushed cache and now it works.
Not sure of what of the above did the trick, tho.

jhans’s picture

Hi

it did the trick. Thanks but know there is an space character at the beginning which looks not really very good. Another chance to return a null value. The first solution works but 00:00 is returned.

Thanks
Joachim

Ingumsky’s picture

Status: Closed (fixed) » Active

In his post #4 yakker made a statement I wanted.
The behaviour of the date module sometimes is really annoying.
My situation:
1. latest stable date module;
2. no _to_ date field (set to never) ;
3. granularity is set to "minutes";
4. Time zone handling is set to "Users".
Almost all users can see correct date and time but some of them receive that "All day" thing that clearly upset them. Why did they see that? Because of their time zone - when it's December 2nd, 6pm in UK it is December 3rd, 12am in Almaty. The date module cannot handle it properly. And those lads wonder what the hell with their time settings at my website. And I'm quite sure there's the same issue with any dates set to 12am and Users time zone disabled.

I don't want to use the workaround mentioned above and disable date_all_day_label theming function because I need "All day" functionality on some nodes but I want to find a solution.

rlmumford’s picture

Is this the same for drupal 7?

tim.plunkett’s picture

Status: Active » Fixed

This was fixed as of comment #2. Comment #18 might be a duplicate of #1041428: Improper logic in date_field_all_day.

jasom’s picture

or you can print this to avoid error and have no (even empty) characters:


function theme_date_all_day_label() {
  return t('');
}

endiku’s picture

I find the template.php solution to be heavy handed and not a true solution. I state my case #1017216: custom date format without time shows "all day"

The real issue is that custom date/times created in Admin->Date and Time, that are created to display no time at all are ignored and display "All day". Even if you create a custom date display of "M d" which does not refer to time at all, if the date is an zero time/all-day time then "All day" will display. This means that Date's theme_date_all_day function is in conflict with custom date creation. This obviously affects Views use of custom date selection but goes beyond Views as custom Date and Time is really a core issue.

If a custom date/time is created that explicitly does not display time then "All day" just shouldn't be showing up. Tampering with template.php is not a real solution here.

tim.plunkett’s picture

@endiku, the theme function exists for that purpose. I wouldn't call it "heavy-handed".

2dareis2do’s picture

Many thanks

wiizzard’s picture

Version: 6.x-2.x-dev » 7.x-1.x-dev
Status: Fixed » Active

This bug still exists for me in 7.x. Patch from #21 gives me 00:00 instead of nothing.
I have also tried it with patch applied from #1041428.

tribsel’s picture

hi! what if you want to show date in some view without 'All day' appendix and but somewhere else with that appendix (like in the calendar).

btopro’s picture

Theme Agnostic "fix" to this issue (at least in D6, didn't test in D7)

function YOURMODULENAME_theme_registry_alter(&$vars) {
  //date all day label fix so it doesn't say "All day" for null values
  $vars['date_all_day_label']['theme path'] = drupal_get_path('module','YOURMODULENAME');
  $vars['date_all_day_label']['function'] = 'YOURMODULENAME_date_all_day_label';
  $vars['date_all_day_label']['theme paths'] = array(0 => drupal_get_path('module','YOURMODULENAME'));
}

function YOURMODULENAME_date_all_day_label() {
  return t('');
}
KarenS’s picture

Version: 7.x-1.x-dev » 6.x-2.x-dev
Status: Active » Fixed

Please don't move issues from one version to another, the code is totally different. Plus this is already an issue that has veered off in too many directions.

Each issue should be about one problem in one version so we can focus on that problem and close it when fixed.

Status: Fixed » Closed (fixed)

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

fmitchell’s picture

Better than doing a theme override, remove the granularity from your field settings (also required to remove the timezone) from 'hour, seconds' to just day.

Ingumsky’s picture

>>fmitchell
You didn't get the point mate. The problem is: there're some values _with_ hours and minutes set and at the same time there're some values _without_ them. Let me explain: I have two events (i.e football games) scheduled on June 23th and July 23th. I know kick-off time for the first game is 3pm but I don't know when another game will start. Granularity settings can not solve the issue for me.

marcos.518’s picture

Component: Date CCK Field » Code

thanks lucio.ferrari owe you a lunch. =)

diannaL’s picture

Not sure if this will be of any use to anyone (but you never know). For various reasons only our developer has access to the code of our Drupal site so we were forced to find a solution to this problem using only views. (His time is very limited too)

*Our events are a mix of All Day events and by hour slot events, so we couldn't change the CCK field granularity.

We wanted a list of upcoming events split by month in the view.

To make this happen we had to create a field for the month (trimmed to three characters, and excluded from display) and a field for the year (trimmed to four characters and excluded from the display). Then add these together in a custom text field.
Sort in the table by this custom text field.

jayson’s picture

Hi momper and others who may be interested, I know this post is old and closed, but I had the same problem as you did just now. I have an date event with a time granularity, but I want to allow some dates with time and others without - but I never want the "(All day)" to appear. Here's how I solved it:

I updated my template.php file and added this code to the end of the file:

/* Wrap the Date module's "(All day)" text with a span tag */
function [your-theme-name]_date_all_day_label() {
  return '<span class="date-all-day-info">('. date_t('All day', 'datetime') .')</span>';
}

Then, I put this in my stylesheet to hide the (All day).
.date-all-day-info {display:none;}

I like this solution best because I did not have to patch the Date module, and can now control the display of the (All day) easily through my stylesheet.

I'd recommend that the module developer simply put a span tag around the (All day) info in their module and this will allow us all the flexibility we need.

Hope this helps,
Jayson

JohnLinux’s picture

This is misleading. removed the option of having hours and minutes on your site. and no timezones

commonpike’s picture

Issue summary: View changes

I don't see what's misleading about what @jayson said. It works and disables nothing, but i had to fix the 'date_t' call:

function [yourmodule]_date_all_day_label() {
  return '<span class="date-all-day-label">('. t('All day', array('context'=>'datetime')) .')</span>';
}

and

.date-all-day-label {display:none;}