Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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?
Comment | File | Size | Author |
---|---|---|---|
#24 | Fix_All_Day_Logic_D6-1017216-24.patch | 1.53 KB | arlinsandbulte |
#21 | Fix_All_Day_Logic-1017216-21.patch | 1.49 KB | arlinsandbulte |
#18 | date-1017216-18.patch | 1.07 KB | tim.plunkett |
#16 | date-1017216-16.patch | 1.06 KB | tim.plunkett |
Comments
Comment #1
dperdue CreditAttribution: dperdue commentedThe function
theme_date_all_day_label
is used to change the all day label. So something like:in your template.php should do the trick.
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedyes that did it - thanks so much!
closing since it's resolved
Comment #3
iantresman CreditAttribution: iantresman commentedI'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.
Comment #4
iantresman CreditAttribution: iantresman commentedBy the way, the fix worked for me too, but
<?php .. ?>
tagsI had other examples in my template.php file in my theme directory.
Comment #5
endiku CreditAttribution: endiku commentedI 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
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.
Comment #6
Rob T CreditAttribution: Rob T commentedThanks from me as well.
Comment #7
ksweet CreditAttribution: ksweet commented@endiku This fix worked great for me. Thank you so much!
Comment #8
Pepe Roni CreditAttribution: Pepe Roni commentedI 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.
Comment #9
kevinquillen CreditAttribution: kevinquillen commentedCan 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.
Comment #10
bomarmonk CreditAttribution: bomarmonk commentedUsing 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:
Comment #11
garbo CreditAttribution: garbo commentedThanks for the trick @dperdue!
comment #1 is an quick and easy site-wide fix.
Comment #12
botris#5 doesn't seem to work for localized dates.
Tried with date() first en then:
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.
Comment #13
botris#5 doesn't seem to work for localized dates.
Tried with date() first en then:
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.
Comment #14
botrisFix it by using format_date():
This replaces the localized 'All day' only at the place where you want it replaced.
Comment #15
vulfox CreditAttribution: vulfox commentedI 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.
Comment #16
tim.plunkettSee attached.
Comment #17
files32 CreditAttribution: files32 commentedThanks. The patch works.
Comment #18
tim.plunkettI 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.
Comment #19
tim.plunkettAlso, this should be fixed in D7 as well. The code is similar, but different enough that I'll have to rewrite it.
Comment #20
arlinsandbulte CreditAttribution: arlinsandbulte commentedI 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:
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).
Comment #21
arlinsandbulte CreditAttribution: arlinsandbulte commentedHere is the patch that implements #20 above (for D7)
Comment #23
arlinsandbulte CreditAttribution: arlinsandbulte commented#21: Fix_All_Day_Logic-1017216-21.patch queued for re-testing.
Comment #24
arlinsandbulte CreditAttribution: arlinsandbulte commentedAnd 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.
Comment #25
arlinsandbulte CreditAttribution: arlinsandbulte commentedShould have left this at 7.x-2.x....
Comment #26
tim.plunkettI'll take a look at this tonight, hopefully.
Comment #27
arlinsandbulte CreditAttribution: arlinsandbulte commentedNo 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
Comment #28
spgd01 CreditAttribution: spgd01 commented6.x-2.8+9-dev
Still has the issue
Comment #29
spgd01 CreditAttribution: spgd01 commentedI re-loaded 6.x-2.8+9-dev and it works now. Thanks
Comment #31
Carlos Miranda Levy CreditAttribution: Carlos Miranda Levy commentedThe 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.
Comment #32
DamienMcKennaPlease open a new issue for any additional changes to this issue. Thank you.