I have a custom date format that shows the day of the week, month and date:
Since I updated modules, it started displaying "all day" for nodes that don't have times specified - even though there is no call for time to be displayed.
Any thoughts about how to fix this - other than changing all the no-time nodes to have a fictitious start time?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dperdue’s picture

The function theme_date_all_day_label is used to change the all day label. So something like:

function THEMENAME_date_all_day_label() {
  return '';
}

in your template.php should do the trick.

Anonymous’s picture

Status: Active » Closed (fixed)

yes that did it - thanks so much!
closing since it's resolved

iantresman’s picture

Status: Closed (fixed) » Needs review

I'd like to see the previous functionality restored, i.e if there is no time specified, then nothing is displayed. Otherwise I have to update all my sites. I can always rewrite the date field to append "All day" if I wish.

iantresman’s picture

By the way, the fix worked for me too, but

  • I didn't need to the <?php .. ?> tags
  • I had to clear the cache (in Admin/peformance).
  • An obviously you need to change "THEMENAME" to your theme name.
    I had other examples in my template.php file in my theme directory.
endiku’s picture

I hesitate to call this fixed because of the following scenario

If you create a custom date/time in "Date and Time". Then create a View using a date field where you refer to that custom date/time where the display excludes a time (for example- date("M") where you only want the Month to display)... and the date in question is an zero time date, then instead of display just the month you end up with Month (All day).

On the surface this seems like a Views module issue and not a Date module issue. However Views is being using correctly. The Custom Date chosen is that of a non-time display and it is being selected correctly in the Views date display format. Now whether Views needs a patch to better utilize the custom date to bypass the all day function of date versus Date being more discriminate in its "all day" function, I am unsure.

The manipulation of template.php however seems to me to be both a poor and heavy handed solution here. Some instances the "All day" is warranted and some not. If a custom date where time is displayed is chosen then the "All day" would be replaced by 12:00 am which is hardly a better solution. And manipulating template.php to resolve this is very hackish.

For those who have this issue with Views or Calendar I would suggest to instead use Customfield in Views. Create a customfield PHP Code field and manually create your date display instead of relying on Admin->Date and Time's custom date selections. Simply add your Content Date to fields, exclude it, then add the customfield php under it. In the php code value use something like

echo date("M", strtotime($data->node_data_field_date_field_date_value));

which will display the short Month format for example. Then you can group by the customfield or use it however you wish as you would use the straight Date field in the View.

Rob T’s picture

Thanks from me as well.

ksweet’s picture

@endiku This fix worked great for me. Thank you so much!

Pepe Roni’s picture

I also ran into this problem: I defined a datetime field (with from and optional to-date and time) and wanted to display the date part only in a block view. I want to display "(All day)" or the starting and ending time in the teaser view and also in full view. So to overwrite the theme function was no solution for me.

I expected to display no time information (and "(All day)" is a time information in my opinion), if I use a "date only" format(ter). I would consider this a bug and not a support request. This should be solved by a format(ter) with the option to display "(All day)" if the starting time has a certain value and an ending time is not provided.

To say 0:00 (12:00am) as the time to consider "(All day)" is not a solution, as you will run into problems with repeating dates: If you format the date in a display to print only the next 4 upcoming dates, today is not included (now is current time and that's usually greater than current date 0:00. So for this purpose 23:59 (11:59pm) would be better suited.

kevinquillen’s picture

Can there just be a checkbox with the date widget that says 'Display as All Day' on the node where date is being input?

What if you have one date field, without a To, and it does not have a time? It shows up as All Day for me, but thats not how I am intending to use the field. In fact, I don't want it to say All Day, ever.

bomarmonk’s picture

Using the code for a custom field in views, the day ends up being one day off with repeating date fields. Any idea on how to modify the code to fix this? I'm using the following code in my custom field:

echo date('m.d.y', strtotime($data->node_data_field_date_field_date_value));
garbo’s picture

Thanks for the trick @dperdue!

comment #1 is an quick and easy site-wide fix.

botris’s picture

#5 doesn't seem to work for localized dates.
Tried with date() first en then:

setlocale(LC_TIME, 'nl_NL');  
$localdate = strftime('%B', strtotime($data->node_data_field_date_field_date_value));
print $localdate;

But views seems to not want to do that, keep display English version, eventhough the 'non manipulated' fields work fine in local language. So #1 remains my only solution at this time.

botris’s picture

#5 doesn't seem to work for localized dates.
Tried with date() first en then:

setlocale(LC_TIME, 'nl_NL');  
$localdate = strftime('%B', strtotime($data->node_data_field_date_field_date_value));
print $localdate;

But views seems to not want to do that, keep display English version, eventhough the 'non manipulated' fields work fine in local language. So #1 remains my only solution at this time.

botris’s picture

Fix it by using format_date():

$localdate = format_date(strtotime($data->node_data_field_date_field_date_value), 'custom',  'F');
$localdate = str_replace('Gehele dag', '', $localdate);
print $localdate;

This replaces the localized 'All day' only at the place where you want it replaced.

vulfox’s picture

I also tested setlocale.

I even tried putting it in page.tpl.php. setlocale seems to be ignored. But in page.tpl.php the time is displayed correctly.

So just to clarify once more:
An example:
- User inputs an event without a time and and the time is automatically set to 00:00
- When I use customfield in views to output the time it's suddenly 22:00 on the day before (= two hours before ),

-- Why two hours?
The time zone of the site is +2 GMT

-- Why is this a problem?
Because the start date is shown incorrectly as day before.

I could add two hours (7200 seconds), but how to compensate for daylight saving (the time zone becomes +3 GMT)

PS. I really wish they would find a solution to "All day" problems i Date module. There are really many of them.

tim.plunkett’s picture

Version: 6.x-2.7 » 6.x-2.x-dev
Category: support » feature
FileSize
1.06 KB

See attached.

files32’s picture

Thanks. The patch works.

tim.plunkett’s picture

FileSize
1.07 KB

I believe conditionals are evaluated from right to left, but to prevent any ambiguity and future mistakes, this moves the assignment for $all_day out of the conditional.

tim.plunkett’s picture

Also, this should be fixed in D7 as well. The code is similar, but different enough that I'll have to rewrite it.

arlinsandbulte’s picture

Version: 6.x-2.x-dev » 7.x-2.x-dev
Assigned: Unassigned » arlinsandbulte
Status: Needs review » Needs work

I am working on a Patch for this in D7.
The logic is a bit confusing... and I don't mean the code, but rather when to show the 'All Day' value and when not to depending on both the Date field's granularity & the display format used.

Here is the logic I am applying:

  • If the Date Field's granularity does not include time (which means granularity does not include Hour), 'All Day' will NEVER be appended to the end of the date when it is displayed.
  • If the Date Field's granularity does include time AND the display format includes time (which means the php format string includes g, G, h, and/or H), then 'All Day' will be appended to the date when it is displayed and the date values meet the all day requirements of date_all_day_field().
  • If the Date Field's granularity does include time AND the display format does not include time (which means the php format string does not include g, G, h, and/or H), then 'All Day' will never be appended to the date when it is displayed.

Please review the above logic and confirm I am heading down the right path.
I should have a patch available soon (I'm really close right now).

arlinsandbulte’s picture

Assigned: arlinsandbulte » Unassigned
Status: Needs work » Needs review
FileSize
1.49 KB

Here is the patch that implements #20 above (for D7)

Status: Needs review » Needs work

The last submitted patch, Fix_All_Day_Logic-1017216-21.patch, failed testing.

arlinsandbulte’s picture

Status: Needs work » Needs review

#21: Fix_All_Day_Logic-1017216-21.patch queued for re-testing.

arlinsandbulte’s picture

Version: 7.x-2.x-dev » 6.x-2.x-dev
FileSize
1.53 KB

And here is the same patch as #21, ported to Date 6.x-2.x for review.
Note: Date 6.x-2.x testes are broken right now, so this will probably fail tests. But in my manual testing it worked just as I intended.

arlinsandbulte’s picture

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

Should have left this at 7.x-2.x....

tim.plunkett’s picture

Assigned: Unassigned » tim.plunkett

I'll take a look at this tonight, hopefully.

arlinsandbulte’s picture

Assigned: tim.plunkett » Unassigned
Status: Needs review » Fixed

No feedback after a week, so I went ahead and committed this to both 6.x & 7.x:

6.x-2.x commit: http://drupalcode.org/project/date.git/commit/2155e69
7.x-2.x commit: http://drupalcode.org/project/date.git/commit/a7490ab

spgd01’s picture

6.x-2.8+9-dev

Still has the issue

spgd01’s picture

I re-loaded 6.x-2.8+9-dev and it works now. Thanks

Status: Fixed » Closed (fixed)

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

Carlos Miranda Levy’s picture

Status: Closed (fixed) » Active

The stated logic leaves out the common situation where you want time granularity available for your events, yet some won't have any time specified and you don't want the ugly (All day) appended to the date.

In my case, we are making a list of literary competitions from multiple sources, some list the time and the date for submissions, while others only list the date.
We want to be able to display the date and time for those that have a time indicated and just the date -- without (All day) -- for those that don't.

Such a case, and a solution is listed at:
http://drupal.org/node/367842#comment-6982626

Basically add a wrapper around the "(All day)" tag and we can take care of it via .css or rewriting the output in the View.

DamienMcKenna’s picture

Issue summary: View changes
Status: Active » Fixed

Please open a new issue for any additional changes to this issue. Thank you.

Status: Fixed » Closed (fixed)

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