What's about support for date time field?
There is:

        elseif ($field['type'] == 'date' && $field['todate'] == 'required' && $field['required']) {
          $date_fields[$field['field_name']] = $field['widget']['label'];
        }

My solution:

        elseif (($field['type'] == 'date' || $field['type'] == 'datetime') && $field['todate'] == 'required' && $field['required']) {
          $date_fields[$field['field_name']] = $field['widget']['label'];
        }

But I didn't test it if it will work.

Comments

kenorb’s picture

Version: 5.x-2.x-dev » 6.x-2.x-dev
pdcarto’s picture

Are there any plans to address this feature request?

pdcarto’s picture

I would expand this feature request as follows:

Support all date field types. RC should not fail to work just because a content type doesn't use its preferred date field type.

redben’s picture

Priority: Normal » Critical

I would have expected this behaviour (not supporting datetime) I too think it is a must have.
So +1

redben’s picture

Version: 6.x-2.x-dev » 6.x-2.0
Status: Active » Needs review
StatusFileSize
new1.28 KB

I have made a patch to resource_conflict.module including the code from knorb and changed _resource_conflict_overlaps_from_date tp support date_make_date from DATE_DATETIME format. It is my first contributed patch, if there is a problem please tell me and i'll correct it. Note that the patch has been made against version 2.0

@@ -147,7 +147,7 @@ function resource_conflict_form_alter(&$
         if ($field['type'] == 'nodereference') {
           $nodereference_fields[$field['field_name']] = $field['widget']['labe$
         }
-        elseif ($field['type'] == 'date' && $field['todate'] == 'required' && $
+        elseif (($field['type'] == 'date' || $field['type'] == 'datetime') && $
           $date_fields[$field['field_name']] = $field['widget']['label'];
         }
       }
@@ -326,8 +326,13 @@ function _resource_conflict_get_node_res
  *   An array of node ID's
  */
 function _resource_conflict_overlaps_from_date($date_start, $date_end) {
-  $start = date_make_date($date_start, 'GMT', DATE_ISO);
-  $end = date_make_date($date_end, 'GMT', DATE_ISO);
+  // make default type to DATE_ISO
+  $type = DATE_ISO;
+  // if date_start is not in DATE_ISO set type to DATE_DATETIME
+  if (!date_is_valid($date_start,DATE_ISO)) $type = DATE_DATETIME;
+
+  $start = date_make_date($date_start, 'GMT', $type);
+  $end = date_make_date($date_end, 'GMT', $type);
   return _resource_conflict_get_overlaps($start, $end);
 }

redben’s picture

Forgot to mention that i tested it with my datetime field and it worked as expected :-)

deviantintegral’s picture

Version: 6.x-2.0 » 6.x-2.x-dev
Priority: Critical » Normal
Status: Needs review » Needs work

Thanks redben for the patch. A few notes:

  • Critical is for issues where things actually break, not for new features
  • Always roll patches against the latest -dev version, though in this case it should be OK as they are nearly identical.
  • Single line comments should start with a capital and end with a period.
  • The if statement should be on two lines.

Otherwise, it looks good - it'd be great if someone else tested this too.

finex’s picture

I've tested the patch and it is works fine.

deviantintegral’s picture

Status: Needs work » Fixed
StatusFileSize
new1.56 KB

Thanks FiNeX for the testing. I've fixed the code style and committed this to CVS.

garg’s picture

I don't know if this is required for this, but for completeness should this be changed as well?

Inside function _resource_conflict_display_conflict_errors it currently says:

    // display the error for each conflict
    foreach ($conflicting_resources as $conflicting_resource) {
      $date_field = variable_get('rc_date_field_'. $conflicting_node->type, FALSE);
      if (strpos($date_field, 'field_', 0) === 0) {
        $start = format_date(date_convert($conflicting_node->{$date_field}[0]['value'], DATE_ISO, DATE_UNIX));
        $end   = format_date(date_convert($conflicting_node->{$date_field}[0]['value2'], DATE_ISO, DATE_UNIX));
      }

Changed to:

      if (strpos($date_field, 'field_', 0) === 0) {
        $type = DATE_ISO;
        // If date_start is not in DATE_ISO set the type to DATE_DATETIME.
        if (!date_is_valid($date_start,DATE_ISO)) {
          $type = DATE_DATETIME;  
        }
      
        $start = format_date(date_convert($conflicting_node->{$date_field}[0]['value'], $type, DATE_UNIX));
        $end   = format_date(date_convert($conflicting_node->{$date_field}[0]['value2'], $type, DATE_UNIX));
deviantintegral’s picture

@garg, it'd be great if you could wrap your code with <code> tags. Or better yet, create a patch file.

That change seems reasonable; can you verify it's broken in the current -dev release?

garg’s picture

StatusFileSize
new1.11 KB

I edited my first message and added the code tags. The current -dev tarball does not have the proposed change. I have attached a patch file to this message.

I hope I'm doing this right.

edit: Oops, I just noticed the naming convention for patches. I'll remember that for next time.

Status: Fixed » Closed (fixed)

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

deviantintegral’s picture

Status: Closed (fixed) » Needs review

This never got re-opened.

nhck’s picture

Title: datetime doesn't work with CCK » Support CCK datetime
Priority: Normal » Critical
Status: Needs review » Reviewed & tested by the community

This must so definitly go in! I was surpised at first that it wouldn't work w/ datetime. After upgrading to dev and applying this patch it is so nice. Please get this out the door soon :-)

I tested it and it works. Nice stuff. So nice.

deviantintegral’s picture

Status: Reviewed & tested by the community » Fixed

I've committed the patch in #12, along with some whitespace code style fixes.

Status: Fixed » Closed (fixed)

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