Index: date/date_all_day.js =================================================================== --- date/date_all_day.js (revision 0) +++ date/date_all_day.js (revision 0) @@ -0,0 +1,197 @@ +function addDefaultDate(default_year, default_month, default_day, fieldClass) { + var currentDate = new Date(); + currentDate.setFullYear(default_year, default_month, default_day); + var curr_month = currentDate.getMonth() + 1; + var curr_day = currentDate.getDate(); + var curr_year = currentDate.getFullYear(); + + var mm = new String(curr_month); + var dd = new String(curr_day); + if ( mm.length == 1 ) mm = "0" + mm; // Add leading zeros to month and day if required + if ( dd.length == 1 ) dd = "0" + dd; + var curr_date = curr_year+'-'+mm+'-'+dd; + + if($("#edit-"+fieldClass+"-0-value-day").val() == "") { + $("#edit-"+fieldClass+"-0-value-day").val(curr_day); + } + if($("#edit-"+fieldClass+"-0-value-month").val() == "") { + $("#edit-"+fieldClass+"-0-value-month").val(curr_month); + } + if($("#edit-"+fieldClass+"-0-value-year").val() == "") { + $("#edit-"+fieldClass+"-0-value-year").val(curr_year); + } + if($("#edit-"+fieldClass+"-0-value-hour").val() == "") $("#edit-"+fieldClass+"-0-value-hour").val("1"); + if($("#edit-"+fieldClass+"-0-value-minute").val() == "") $("#edit-"+fieldClass+"-0-value-minute").val("00"); + if($("#edit-"+fieldClass+"-0-value-ampm").val() == "") $("#edit-"+fieldClass+"-0-value-ampm").val("am"); + + $("#edit-"+fieldClass+"-0-value-date").val(curr_date); + $("#edit-"+fieldClass+"-0-value-time").val('00:00'); +} + +function dateAllDayToggle (is_checked, fieldClass, is_required) { + if (is_checked) { + DateAllDayYes(fieldClass); + } + else { + DateAllDayNo(fieldClass, is_required); + } +} + +function DateAllDayYes(fieldClass) { + var currentDate = new Date(); + var curr_hours = currentDate.getHours() + 1; + var curr_minutes = currentDate.getMinutes() + 1; + var curr_month = currentDate.getMonth() + 1; + var mm = new String(curr_month); + var curr_day = currentDate.getDate(); + var dd = new String(curr_day); + var curr_year = currentDate.getFullYear(); + + if ( mm.length == 1 ) mm = "0" + mm; // Add leading zeros to month and day if required + if ( dd.length == 1 ) dd = "0" + dd; + + var curr_date = curr_year+'-'+mm+'-'+dd; + + if($("#edit-"+fieldClass+"-0-value2-day").val() == "") { + if ($("#edit-"+fieldClass+"-0-value-day").val() != "") $("#edit-"+fieldClass+"-0-value2-day").val($("#edit-"+fieldClass+"-0-value-day").val()); + else $("#edit-"+fieldClass+"-0-value2-day").val(curr_day); + } + if($("#edit-"+fieldClass+"-0-value2-month").val() == "") { + if ($("#edit-"+fieldClass+"-0-value-month").val() != "") $("#edit-"+fieldClass+"-0-value2-month").val($("#edit-"+fieldClass+"-0-value-month").val()); + else $("#edit-"+fieldClass+"-0-value2-month").val(curr_month); + } + if($("#edit-"+fieldClass+"-0-value2-year").val() == "") { + if ($("#edit-"+fieldClass+"-0-value-year").val() != "") $("#edit-"+fieldClass+"-0-value2-year").val($("#edit-"+fieldClass+"-0-value-year").val()); + else $("#edit-"+fieldClass+"-0-value2-year").val(curr_year); + } + + if($("#edit-"+fieldClass+"-0-value-day").val() == "") { + if ($("#edit-"+fieldClass+"-0-value2-day").val() != "") $("#edit-"+fieldClass+"-0-value-day").val($("#edit-"+fieldClass+"-0-value2-day").val()); + else $("#edit-"+fieldClass+"-0-value-day").val(curr_day); + } + + if($("#edit-"+fieldClass+"-0-value-month").val() == "") { + if ($("#edit-"+fieldClass+"-0-value2-month").val() != "") $("#edit-"+fieldClass+"-0-value-month").val($("#edit-"+fieldClass+"-0-value2-month").val()); + else $("#edit-"+fieldClass+"-0-value-month").val(curr_month); + } + + if($("#edit-"+fieldClass+"-0-value-year").val() == "") { + if ($("#edit-"+fieldClass+"-0-value2-year").val() != "") $("#edit-"+fieldClass+"-0-value-year").val($("#edit-"+fieldClass+"-0-value2-year").val()); + else $("#edit-"+fieldClass+"-0-value-year").val(curr_year); + } + + if($("#edit-"+fieldClass+"-0-value2-date").val() == "") { + if (($("#edit-"+fieldClass+"-0-value-date").val() != "") && ($("#edit-"+fieldClass+"-0-value-date").val() != undefined)) $("#edit-"+fieldClass+"-0-value2-date").val($("#edit-"+fieldClass+"-0-value-date").val()); + else $("#edit-"+fieldClass+"-0-value2-date").val(curr_date); + } + + if($("#edit-"+fieldClass+"-0-value-date").val() == "") { + if (($("#edit-"+fieldClass+"-0-value2-date").val() != "") && ($("#edit-"+fieldClass+"-0-value2-date").val() != undefined)) $("#edit-"+fieldClass+"-0-value-date").val($("#edit-"+fieldClass+"-0-value2-date").val()); + else $("#edit-"+fieldClass+"-0-value-date").val(curr_date); + } + + if($("#edit-"+fieldClass+"-0-value-hour").val() == "") { + if ($("#edit-"+fieldClass+"-0-value-ampm").val() == undefined) { + $("#edit-"+fieldClass+"-0-value-hour").val("0"); + } + else { + $("#edit-"+fieldClass+"-0-value2-hour").val("1"); + if($("#edit-"+fieldClass+"-0-value-ampm").val() == "") $("#edit-"+fieldClass+"-0-value-ampm").val("am"); + } + } + if($("#edit-"+fieldClass+"-0-value-minute").val() == "") $("#edit-"+fieldClass+"-0-value-minute").val("00"); + + if ($("#edit-"+fieldClass+"-0-value2-ampm").val() == undefined) { + $("#edit-"+fieldClass+"-0-value2-hour").val("23"); + } + else { + $("#edit-"+fieldClass+"-0-value2-hour").val("11"); + $("#edit-"+fieldClass+"-0-value2-ampm").val("pm"); + } + $("#edit-"+fieldClass+"-0-value2-minute").val("59"); + + if ($("#edit-"+fieldClass+"-0-value-time").val() == "") { + $("#edit-"+fieldClass+"-0-value-time").val('00:00'); + } + if ($("#edit-"+fieldClass+"-0-value2-time").val() == "") { + $("#edit-"+fieldClass+"-0-value2-time").val('23:59'); + } +} + +function DateAllDayNo(fieldClass, is_required) { + var currentDate = new Date(); + var curr_hours = currentDate.getHours() + 1; + var curr_minutes = currentDate.getMinutes() + 1; + var curr_month = currentDate.getMonth() + 1; + var mm = new String(curr_month); + var curr_day = currentDate.getDate(); + var dd = new String(curr_day); + var curr_year = currentDate.getFullYear(); + + if (is_required == "") is_required = "0"; + + if ( mm.length == 1 ) mm = "0" + mm; // Add leading zeros to month and day if required + if ( dd.length == 1 ) dd = "0" + dd; + + var curr_date = curr_year+'-'+mm+'-'+dd; + + if((($("#edit-"+fieldClass+"-0-value2-day").val() == curr_day) || ($("#edit-"+fieldClass+"-0-value2-day").val() == $("#edit-"+fieldClass+"-0-value-day").val())) + && (($("#edit-"+fieldClass+"-0-value2-month").val() == curr_month) || ($("#edit-"+fieldClass+"-0-value2-month").val() == $("#edit-"+fieldClass+"-0-value-month").val())) + && (($("#edit-"+fieldClass+"-0-value2-year").val() == curr_year) || ($("#edit-"+fieldClass+"-0-value2-year").val() == $("#edit-"+fieldClass+"-0-value-year").val())) + && (((($("#edit-"+fieldClass+"-0-value2-hour").val() == "11") || ($("#edit-"+fieldClass+"-0-value2-hour").val() == "23")) && ($("#edit-"+fieldClass+"-0-value2-minute").val() == "59") + && ($("#edit-"+fieldClass+"-0-value2-ampm").val() == "pm")) + || (((($("#edit-"+fieldClass+"-0-value2-hour").val() == "11") || ($("#edit-"+fieldClass+"-0-value2-hour").val() == "23")) && ($("#edit-"+fieldClass+"-0-value2-minute").val() == "59")) + && ($("#edit-"+fieldClass+"-0-value2-ampm").val() == undefined))) + ) { + $("#edit-"+fieldClass+"-0-value2-year").val("") + $("#edit-"+fieldClass+"-0-value2-month").val("") + $("#edit-"+fieldClass+"-0-value2-day").val(""); + $("#edit-"+fieldClass+"-0-value2-minute").val(""); + $("#edit-"+fieldClass+"-0-value2-hour").val(""); + $("#edit-"+fieldClass+"-0-value2-ampm").val(""); + } + + if ((($("#edit-"+fieldClass+"-0-value-day").val() == curr_day) + || ($("#edit-"+fieldClass+"-0-value-day").val() == $("#edit-"+fieldClass+"-0-value2-day").val()) + || ($("#edit-"+fieldClass+"-0-value2-day").val() == "") + ) + && (($("#edit-"+fieldClass+"-0-value-month").val() == curr_month) + || ($("#edit-"+fieldClass+"-0-value-month").val() == $("#edit-"+fieldClass+"-0-value2-month").val()) + || ($("#edit-"+fieldClass+"-0-value2-month").val() == "") + ) + && (($("#edit-"+fieldClass+"-0-value-year").val() == curr_year) + || ($("#edit-"+fieldClass+"-0-value-year").val() == $("#edit-"+fieldClass+"-0-value2-year").val()) + || ($("#edit-"+fieldClass+"-0-value2-year").val() == "") + ) + && (((($("#edit-"+fieldClass+"-0-value-hour").val() == "0") || ($("#edit-"+fieldClass+"-0-value-hour").val() == "1")) && ($("#edit-"+fieldClass+"-0-value-minute").val() == "00") + && ($("#edit-"+fieldClass+"-0-value-ampm").val() == "am")) + || ((($("#edit-"+fieldClass+"-0-value-hour").val() == "0") || ($("#edit-"+fieldClass+"-0-value-hour").val() == "1")) && ($("#edit-"+fieldClass+"-0-value-minute").val() == "00")) + && ($("#edit-"+fieldClass+"-0-value-ampm").val() == undefined)) + && (is_required == "0") + ) { + $("#edit-"+fieldClass+"-0-value-year").val(""); + $("#edit-"+fieldClass+"-0-value-month").val(""); + $("#edit-"+fieldClass+"-0-value-day").val(""); + $("#edit-"+fieldClass+"-0-value-minute").val(""); + $("#edit-"+fieldClass+"-0-value-hour").val(""); + $("#edit-"+fieldClass+"-0-value-ampm").val(""); + } + + if ((($("#edit-"+fieldClass+"-0-value2-date").val() == curr_date) && ($("#edit-"+fieldClass+"-0-value-date").val() == curr_date)) + || (($("#edit-"+fieldClass+"-0-value2-date").val() == undefined) && ($("#edit-"+fieldClass+"-0-value-date").val() == curr_date)) + || ($("#edit-"+fieldClass+"-0-value2-date").val() == $("#edit-"+fieldClass+"-0-value-date").val())) { + $("#edit-"+fieldClass+"-0-value-date").val(""); + } + + if (($("#edit-"+fieldClass+"-0-value2-date").val() == curr_date) || ($("#edit-"+fieldClass+"-0-value2-date").val() == $("#edit-"+fieldClass+"-0-value-date").val()) + || ($("#edit-"+fieldClass+"-0-value-date").val() == "")) { + $("#edit-"+fieldClass+"-0-value2-date").val(""); + } + + if ($("#edit-"+fieldClass+"-0-value-time").val() == "00:00") { + $("#edit-"+fieldClass+"-0-value-time").val(""); + } + if ($("#edit-"+fieldClass+"-0-value2-time").val() == "23:59") { + $("#edit-"+fieldClass+"-0-value2-time").val(""); + } +} Index: date_api.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/date/date_api.module,v retrieving revision 1.64.2.5.2.63 diff -u -p -r1.64.2.5.2.63 date_api.module --- date_api.module 11 Feb 2009 22:41:24 -0000 1.64.2.5.2.63 +++ date_api.module 12 Feb 2009 16:03:32 -0000 @@ -29,6 +29,7 @@ define('DATE_FORMAT_ISO', "Y-m-d\TH:i:s" define('DATE_FORMAT_UNIX', "U"); define('DATE_FORMAT_DATETIME', "Y-m-d H:i:s"); define('DATE_FORMAT_ICAL', "Ymd\THis"); +define('DATE_FORMAT_ICAL_DATE', "Ymd"); define('DATE_FORMAT_DATE', 'Y-m-d'); define('DATE_REGEX_ISO', '/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):?(\d{2})?/'); Index: date/date_admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/date/date/date_admin.inc,v retrieving revision 1.40.2.3.2.30 diff -u -p -r1.40.2.3.2.30 date_admin.inc --- date/date_admin.inc 25 Jan 2009 13:03:13 -0000 1.40.2.3.2.30 +++ date/date_admin.inc 12 Feb 2009 16:03:32 -0000 @@ -245,7 +245,7 @@ function _date_field_settings($op, $fiel case 'save': - $options = array('granularity', 'timezone_db', 'tz_handling', 'todate', 'repeat', 'repeat_collapsed', 'default_format'); + $options = array('granularity', 'timezone_db', 'tz_handling', 'todate', 'repeat', 'repeat_collapsed', 'default_format', 'all_day'); return $options; case 'database columns': @@ -298,6 +298,9 @@ function date_columns($field) { $db_columns['offset'] = array('type' => 'int', 'not null' => FALSE, 'sortable' => TRUE); if (!empty($field['todate'])) $db_columns['offset2'] = array('type' => 'int', 'not null' => FALSE, 'sortable' => TRUE); } + if (isset($field['all_day']) && $field['all_day'] == TRUE) { + $db_columns['all_day'] = array('type' => 'int', 'length' => 1, 'not null' => FALSE, 'sortable' => FALSE); + } if (isset($field['repeat']) && $field['repeat'] == 1) { $db_columns['rrule'] = array('type' => 'text', 'not null' => FALSE, 'sortable' => FALSE); } @@ -316,6 +319,7 @@ function date_field_settings_form($field $granularity = array('year', 'month', 'day', 'hour', 'minute'); } $tz_handling = isset($field['tz_handling']) ? $field['tz_handling'] : (date_has_time($granularity) ? 'site' : 'none'); + $all_day = isset($field['all_day']) ? $field['all_day'] : FALSE; // If adding a repeat, override the Content module's handling of the multiple values option. if (module_exists('date_repeat') && date_is_repeat_field($field)) { @@ -362,6 +366,12 @@ function date_field_settings_form($field '#options' => date_timezone_handling_options(), '#description' => $description, ); + $form['all_day'] = array( + '#type' => 'checkbox', + '#title' => t('All-day checkbox'), + '#default_value' => $all_day, + '#description' => t('If turned on, all-day property of the dates can be handled.'), + ); // Force this value to hidden because we don't want to allow it to be changed right now, // but allow it to be a variable if needed. $form['timezone_db'] = array( Index: date/date_elements.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/date/date/date_elements.inc,v retrieving revision 1.46.2.2.2.44 diff -u -p -r1.46.2.2.2.44 date_elements.inc --- date/date_elements.inc 13 Jan 2009 13:49:05 -0000 1.46.2.2.2.44 +++ date/date_elements.inc 12 Feb 2009 16:03:32 -0000 @@ -72,9 +72,16 @@ function _date_field_update($op, &$node, } } } + + if ($item['all_day'] == TRUE) { + $items[$delta]['value'] = date(DATE_FORMAT_DATE, strtotime($items[$delta]['value'])); + if ($field['todate']) { + $items[$delta]['value2'] = date(DATE_FORMAT_DATE, strtotime($items[$delta]['value2'])); + } + } // Special case for ISO dates which may have been given artificial values for // some date parts to make them into valid dates. - if ($field['type'] == DATE_ISO) { + elseif ($field['type'] == DATE_ISO) { $items[$delta]['value'] = date_limit_value($items[$delta]['value'], date_granularity($field), $field['type']); if ($field['todate']) { $items[$delta]['value2'] = date_limit_value($items[$delta]['value2'], date_granularity($field), $field['type']); @@ -182,6 +189,17 @@ function _date_widget(&$form, &$form_sta _date_repeat_widget($element, $field, $items, $delta); $element['rrule']['#weight'] = $field['widget']['weight'] + .4; } + if ($field['all_day'] == TRUE) { + $element['all_day'] = array( + '#title' => t('All-day'), + '#type' => 'checkbox', + '#delta' => $delta, + '#default_value' => $items[$delta]['all_day'], + '#description' => t('Turn on if the date is all-day.'), + '#attributes' => array('onclick' => 'dateAllDayToggle(this.checked, \''. str_replace('_', '-', $field['field_name']) .'\', \''. $field['required'] .'\')'), + ); + drupal_add_js(drupal_get_path('module', 'date') .'/date_all_day.js'); + } return $element; } Index: theme/theme.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/date/theme/Attic/theme.inc,v retrieving revision 1.1.4.29 diff -u -p -r1.1.4.29 theme.inc --- theme/theme.inc 3 Dec 2008 15:44:27 -0000 1.1.4.29 +++ theme/theme.inc 12 Feb 2009 16:03:33 -0000 @@ -144,7 +144,9 @@ function template_preprocess_date_vcalen // Format the event results as iCal expects. $events_in = $vars['events']; $events = array(); + $rows = $vars['rows']; foreach ($events_in as $uid => $event) { + $row = array_shift($rows); // Omit any items with empty dates. if (!empty($event['start'])) { $events[$uid] = $event; @@ -155,9 +157,10 @@ function template_preprocess_date_vcalen else { $events[$uid]['timezone'] = ''; } - $events[$uid]['start'] = date_format($event['start'], DATE_FORMAT_ICAL); + $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']) { - $events[$uid]['end'] = date_format($event['end'], DATE_FORMAT_ICAL); + $events[$uid]['end'] = date_format($event['end'], $date_format); } else { $events[$uid]['end'] = $events[$uid]['start'];