I created support for all-day events.
To use this thing, it's required to configure the date field to day-month-year granularity only (no minute, second, hour!). So you can only have all-day events for the field, it needs to be improved in the future, for example having an all-day checkbox.
You also need to patch date module as well.

Comments

Aron Novak’s picture

StatusFileSize
new3.08 KB
new6.71 KB

Here is the new version of the patch, this includes the previous behaviour and it's possible to have a 'full day' checkbox under the field simply. Currently it only has effect on ical export. Please share your ideas how it should work in the other cases? Just convert the date field on-the-fly into y-m-d (year, month, date) format if turned on?

irtech’s picture

Project:Date» Calendar
Category:feature» support
Status:Needs work» Needs review

Aron thank you so much. I won't be able to test these patches until Thursday, but I'll let you know how it goes.

As far as how 'all day' should function..

Essentially this could be done by just stripping HIS from the data if all-day is checked (no reason to store false data, or alternatively set to 00:00:00-23:59:59) - then as ical (or views) are being built - either check if 'allday' is true, or alternatively check granularity of fields - and theme accordingly.

A very good example of how these 4 types can be displayed (properly!) is with phpicalendar (http://phpicalendar.net/phpicalendar/month.php)

irtech’s picture

In retrospect, I think the HIS data should just be stripped and not stored as 00:00:00-23:59:59 . This is because the themeing of timed and untimed should be different (even if spanning across days). Meaning 'untimed' events should always show in the calendar's 'all day' field (in week views for example), whereas timed events, even if spanning multiple days (e.g. 9am on Monday to 5pm on Friday), should always show the time spans (should not be in 'allday' fields).

Not sure if that makes sense. I can make illustrations if necessary.

KarenS’s picture

Status:Needs review» Needs work

Note that there is another issue about this at #145205: Add 'all day' flag to dates for the part to add the 'all day' option to the date field, so there is some duplication. But no one ever provided a D6 patch there and we have a D6 patch here, so maybe I'll just focus on using this issue for further work.

I don't like adding '.f' to the value, it's going to interfere when we store and retrieve the date values from the database, I'd rather add a field column to store a boolean value. And I prefer 'all_day' to 'full_day' (small issue, just my preference). And one thing the other work provides that is nice js to show/hide the time field depending on the value of the 'all day' flag. So I'd like to work those things in.

KarenS’s picture

Category:support» feature

Change category.

Aron Novak’s picture

StatusFileSize
new6.1 KB
new798 bytes

I reworked the patch, it became much simplier :)
But: I could not solve that date widget should accept short format of dates if the checkbox is turned on.
Now the all_day property is a separate cck field and the stored date is trimmed to Y-m-d.

Any suggestion to overwrite the widget validation (i just guess) that prevents the user to enter Y-m-d into the textfield if longer format is enabled?

KarenS’s picture

Note that there is some more code posted at #145205: Add 'all day' flag to dates that might be useful here. I'll let you see if there's any way to take advantage of it and I suggested vito_a contribute ideas here.

irtech’s picture

Aron,

The most recent patches do not seem to work.

Tried with allday checked and HMS left in (didn't remove) and tried allday checked and clearing HMS fields (still stored HMS data).

I tested this on today's 6.x-2.x-dev of both calendar and date with your multi-day patch and karens' rrule patch.

I'll try to test more later.

Aron Novak’s picture

Which widget did you use? In fact, the Ymd format is only in the database.
"Any suggestion to overwrite the widget validation (i just guess) that prevents the user to enter Y-m-d into the textfield if longer format is enabled?" - I wrote this. So the widget will involve in and shows you a full format date.
Now I will find out what happens inside the widget.

KarenS’s picture

This basically seems to work as I would expect it to. The main thing I'd like to add is some simple jQuery code to show/hide the time elements based on the state of the checkbox. I can wrap them in a 'time' div if that would help. I'll also dig into the validation issues.

KarenS’s picture

Status:Needs work» Fixed

A couple changes I had to make:

1) You hard-coded the field name for the all day field in the calendar module and you can't do that because sometimes the table gets aliased.

2) Your code to adjust the values to remove the time wouldn't work correctly in all field types. The Date API has a type-safe function to do that right, date_limit_value(). That may be why it didn't work right for alvey and that may be been the bug you ran into with text fields.

This works right for me now with all types of fields. I don't have the jquery hide/show that I want, but hopefully someone will provide a patch for that later.

I'm committing this much. If you run into any bugs be sure to report them.

KarenS’s picture

Status:Fixed» Needs work

One more change I think I have to make, as non-intuitive as it sounds. We cannot store something like 2008-02-15 00:00:00 for a field in, say, the Central timezone, because we will end up with some database values for that field's data adjusted to one timezone and other values not timezone-adjusted. And it gets even weirder for timestamp fields since we store a value that appears to be precise to the exact second. Doing Views queries through that inconsistent data would be a nightmare. Plus I would have to change a million other places in the code that assume you can tell what timezone to use by the type of field and add a check whether the individual date is an exception to the field's rule. So in addition to all the different types of timezone handling we have now, by type of field and the field settings of 'none', 'site', 'date', and 'utc', we would have on top of that individual exceptions to those rules for specific dates within those types.

So I'm thinking I actually have to store midnight, in the appropriate timezone, as the database value for this to work right, then the all day flag just affects the theme layer to hide the time in forms and nodes and in the ical export.

KarenS’s picture

I'm going to roll this back temporarily until I can think through all these other implications. I need to get a new release out and I don't want this in it until I'm sure it's working right. The iCal all_day stuff and the ical date format are fine, I just don't want that checkbox option to show up yet.

vito_a’s picture

StatusFileSize
new16.49 KB

I've just set the patch from Aron Novak against the 6.x-2.x-dev from 2009-Feb-14 and seems it's working right for me, so probably it's nothing to worry about. Although it's looking a bit static without javascript.

@KarenS: are you sure we won't need no jQuery besides that one hiding/showing the time fields? I've just made a simple modification to the Aron Novak's allday_date.patch including all the jQuery code from the http://drupal.org/node/145205 , seems that makes it look more friendly for the user. Can you try it? :)

KarenS’s picture

The whole issue of exactly what value these dates will be adjusted to in the database and what timezone they will use is something I have to worry about. It doesn't matter if it works right in the particular way you are using it, it has to work right for every possible type of date, granularity, and timezone option, and everything has to be tested -- storing the value, retrieving the value, displaying it in the node, displaying it in Views, displaying it in the Calendar. I'm not sure storing the value as '00:00:00' is going to work right when other dates for the same field store values that are timezone-adjusted.

I can't make this change without testing all that and I don't have time to test it. I'm getting ready to make a new release of Date and Calendar which will go out without this, after that it can be worked on in -dev if someone wants to try getting it to work and is committed to spending the time needed to be sure that everything about this works correctly for all possible scenarios.

irtech’s picture

I am willing to test as much as necessary - I really need this.

markDrupal’s picture

critical feature for me too!

markDrupal’s picture

I have been trying out these patches, they seem to work well for me.
I should state, I don't deal with timezones so that part is untested.

I did notice that iCal all day events need to end on the day after you actually mean
so for an one day all day event
march 16th
you need and ical like this

DTSTART;TZID=America/Los_Angeles;VALUE=DATE-TIME:20090316
DTEND;TZID=America/Los_Angeles;VALUE=DATE-TIME:20090317

Ended up I needed to add a day to the end date of all day events. (Requires PHP >= 5.2)

So I patched date/theme.inc
from:

<?php
else {
       
$events[$uid]['timezone'] = '';
      }
     
$date_format = ($row->calendar_all_day == TRUE) ? DATE_FORMAT_ICAL_DATE : DATE_FORMAT_ICAL;
     
$events[$uid]['start'] = date_format($event['start'], $date_format);
      if (
$event['start'] && $event['end']) {
?>

To this

<?php
else {
       
$events[$uid]['timezone'] = '';
      }
     
$date_format = ($row->calendar_all_day == TRUE) ? DATE_FORMAT_ICAL_DATE : DATE_FORMAT_ICAL;
      if (
$event['end'] && $row->calendar_all_day == TRUE){
       
$event['end']->modify("+1 day");
      }
     
$events[$uid]['start'] = date_format($event['start'], $date_format);
      if (
$event['start'] && $event['end']) {
?>

SORRY!!
apparently you can't delete files from comment, use the file :

theme_inc_all_day_ical.patch

markDrupal’s picture

StatusFileSize
new14.54 KB

Here is the whole patch, started with patch in #14 above, fixed the compatibility with date popup in the JS file and added my patch from #18

irtech’s picture

All above patches combined for date/calendar 6.x-2.0 (tested and working - so far). Attached below.

irtech’s picture

StatusFileSize
new5.66 KB

Clarification: this doesn't include Vito's "date_all_day.js" file as diff didn't parse the new file. Use his patch above if you really want it (I don't think it is necessary yet).

arlinsandbulte’s picture

subscribing

markDrupal’s picture

StatusFileSize
new16.27 KB

Keeping this up to date because I still need this feature.
Here is a patch that was built from 2.1 version of this module, but it applies to the dev version just find today. I suggest using the dev at least april 21. You may have to modify your ical view as well to get everything working

markfoodyburton’s picture

Hi
just tried the patch in #21 above, and can confirm it works.

I'd ask for 1 less feature :-) -- For me, it seems odd that a date field can be marked as 'all day' in the field configuration, but the user can then choose to mark it as 'not all day' when they are inputting the date... I'd remove that feature - either the thing is all day or it's not :-)
(Or maybe I missed something?)

Also - I believe I'm right in saying all nodes using a data field that is updated in this way (made all day) will have to be edited and saved (with the 'all day' check box ticked)... - Just something to be aware of if your coming to this having already got some data...

Cheers

Mark.

markDrupal’s picture

for some situations you have to present the user with an all day check box. Say for a birthday, you'd put it on the calendar and mark it all day, but if you want to put a birthday party you'd want to put a specific time.

If you want to hide the check box entirely, you can do so in the hook_form_alter of your custom module. I can paste in the code if you're interested.

markfoodyburton’s picture

I agree that both use cases are important, but I think the right thing to do would be to have a check-box on the field form saying "all day optional" or "always all day" - or some such.
I'm not sure 'hiding' the all day thing is the best way of doing it?
This would also mean that 'always all day' events could then be treated as all day irrespective of the time's they (accidentally) had - which would make a lot of sense, in that if you tried with "all day" off and then wanted to switch "all day" on, you would see the effect in the generated ical (rather than having to re-load/save each node)...

(Also, the idea of removing the display of the all day checkbox may not work, as there is currently no way of setting the default to e.g. on in the field form - this is, anyway, probably required? You may want to set the default to "all day" or not -- especially if the user is then going to be able to choose if it's all day...)

Cheers

Mark.

markDrupal’s picture

Project:Calendar» Date
StatusFileSize
new4.22 KB

The remaining issues are in the Date module code. Here is a patch that adds all-day checkbox to date fields

markDrupal’s picture

Status:Needs work» Reviewed & tested by the community

I've been using this a while with no issues, also Mark in #24 also confirms it works

markfoodyburton’s picture

markDrupal,
(mark say hi mark - hi mark :-) )
Can you confirm if the above patch addresses the issue I brought up in #24/#26?

(For me, this is a show stopper right now- even if it were possible to achieve the hook form alter mechanism successfully, which I doubt due to the lack of a default value setting, I can't afford a 're-save' of all my nodes because of a number of side effects that would cause :-( - I should add - that my own problem, and if no-body else needs the sort of functionality I need, then - I'll have to scratch that itch myself one day wont I :-) )

Cheers

Mark.

markDrupal’s picture

No it dosen't have that feature yet. I think its a good idea to change the checkbox into a drop down select box with options
0 - no all day support
1 - All day optional (checkbox for user to pick)
2 - All day always (no user selectable checkbox)

at the moment, I don't have the time to implement this feature.

but I am using the form_Alter to create this functionality using a different custom module,
This is all you would need to do to make your field always "All-day" (As well you should hide the time input field)
add a alldaycheck.module file

<?php
function alldatecheck_form_alter(&$form, $form_state, $form_id) {
  if(
$form_id == 'event_node_form'){
   
$form['field_date'][0]['all_day']['#type'] = 'value';
   
$form['field_date'][0]['all_day']['#value'] = TRUE;
  }
}
?>

add your alldaycheck.info file

<?php
name
= All Day Check Box
description
= Makes all-day events the default
package = Date/Time
version
= 0.9
core
= 6.x
?>

and you have that functionality . you would have to change'field_date' to the name of you cck field, change 'event_node_form' to '_node_form, and you would have to customize it if you have more than one all-day checkbox.

KoCo’s picture

subscribe

gmclelland’s picture

subscribing

arlinsandbulte’s picture

Any news? Is this OK for commit?

markDrupal’s picture

StatusFileSize
new4.04 KB

I just tested it out on a fresh Drupal 6 install. It does indeed work, however not the way you would want it to work when the site uses multiple timezones.

For example: (the way it works currently)
I set an all day event on November 1st for my birthday, I live on the west cost of USA so it is PST -7 (?) and It is stored in the database as November 1, 00:00:00 but when it is displayed it shows October 31 17:00:00 Which is timezone adjusted for the west cost (UTC - 7 hours)

Basically this patch only works for a single time zone if your date&time settings are set to UTC and you don't allow "User configurable time zones". But it does work for my project which requires an iCal feed so desktop clients can download the calendar to their desktop program and see all day event as "All day" and not as from 00:00:00 - 23:59:59.

So we still have to work out how to stop any time zone adjustment to happen. so that way my birthday is on November 1st in all time zones.

This patch is applied to the latest CVS version on the DRUPAL--2-1 branch

markDrupal’s picture

Status:Reviewed & tested by the community» Needs work

This obviously isn't ready yet as the timezone feature breaks the all day checkbox, marking as "needs work"

geerlingguy’s picture

Subscribe - I don't know if I'll have time to look into this quite yet, but I will keep it on my short list of todos. I will be testing it in the coming weeks for a calendar project on which I'm working.

markDrupal’s picture

StatusFileSize
new3.68 KB

A bit further on this, I'm using the patch for the date module in #34.
and with this patch for the calendar module I can use Microsoft Outlook and view all day events as all day events.

Also includes patch that improves ical validation from this issue : #668336: iCal feeds do not pass ical validation

(I should also add, this fixes a problem when you load an Ical feed into outlook, outlook adjusts events All day events without this flag for daylights savings time. So my all day events after DST were shifted one hour ahead. For example: My event on April 1st all day got shifted +1 hour to be an event April 1st 1AM- April 2nd 1AM)

markDrupal’s picture

StatusFileSize
new4.85 KB

Fixed a problem in #37, heres the new patch.
Still requires patch in #34.

rgmpac’s picture

how does one apply the patch to the software ?

Russ

markDrupal’s picture

http://drupal.org/patch/apply

On Linux:

cd sites/all/modules/calendar
patch -p1 < ~/ical-outlook-allday-support.diff

The page above has info for windows & Mac.

jeffschuler’s picture

Project:Calendar» Date
Category:support» feature
Status:Needs review» Needs work

subscribing

NukeHavoc’s picture

subscribing

Where do things sit with this now? Does it need additional testing?

developer-x’s picture

subscribe

Spark_man’s picture

There are like 15 patches in this series - before I go trying install them all (and probably experiencing an epic fail), is there are concise list and order that they need to be installed to get this to work?

webwriter’s picture

subscribe

somanyfish’s picture

In #13, KarenS says "The iCal all_day stuff and the ical date format are fine" but I don't see how to make iCal deliver an all day event. I'm using Calendar 6.x-2.2 and Date 6.x-2.4 and I can create an all day event one of two ways, either with start/end time at 12am or with start time at 12am and end time at 11:59am. In both cases, the node will display with "(All day)" instead of the time, which is great. However the iCal feed delivers the time and doesn't set the All Day flag.

Is this supposed to be fixed as of 2/13/2009, as indicated in #13?

YK85’s picture

subscribing

grasmash’s picture

subscribe.

nkschaefer’s picture

I didn't read through all the posts here, but I think I had the same problem as some of you: my project involves events for which times are excluded/don't matter: multi-day meetings and conferences. I wanted to create an iCal feed for which events would show up as "all day" events when users import the feed into iCal. This isn't 100% tested, but a quick preprocessing hook gave me the outcome I wanted (so far only tested in my Mac's iCal app):

<?php
function MYMODULENAME_preprocess_calendar_view_ical(&$vars){
    if (
$vars['view']->name == 'MYVIEWNAME'){
        foreach(
$vars['events'] as $i => $event){
           
$tStart = strpos($event['start'], 'T');
            if (
$tStart){
               
$vars['events'][$i]['start'] = substr($event['start'], 0, $tStart);
            }
           
$tEnd = strpos($event['end'], 'T');
            if (
$tEnd){
               
$vars['events'][$i]['end'] = substr($event['end'], 0, $tEnd);
            }
        }
    }
}
?>

I just chopped off the portions of the start and end dates that came after the "T", so what's sent to the iCal feed is just year+month+day with no time. My Mac's iCal app interprets these items as "all day events," but I can't vouch for what any other programs will do -- I am no expert on calendars/iCal/ICS files.

Hope this helps someone looking for a quick fix.

seaneffel’s picture

Is there any more momentum for adding "all day" date handling to the Date module? Or did this effort fizzle?

tim.plunkett’s picture

sub

developer-x’s picture

Hi,

I've written a module, Date Tweaks, that adds an "All Day" button to the Date Widget. In addition, it does adds the following:

  1. Adds in Baron Schwartz's date-time javascript functionality
  2. Maintains the date's duration - so when the start date changes, the end date also changes
  3. Adds in Willington Vega's dropdown time picker. By default, this timepicker replaces the standard timepicker
  4. Adds an "All Day" button which toggles the time field. When checked, the start and end time is set to 00:00

Hopefully this handles the UI requirements listed here.

BrightBold’s picture

Subscribe, since it seems like this is a reasonable feature to have in Date core, but in the meantime I'm checking out Date Tweaks. Thanks developer-x!

MrHaroldA’s picture

I don't have time to read all posts in this thread, but I had to hack date_api.module to get my calendar shown on Google Calendar. The date only (Ymd) broke ical standards.

define('DATE_FORMAT_ICAL_DATE', "Ymd\THis");

My ical now validates at various validation sites and Google can parse it too.