Project:Resource Conflict
Version:6.x-2.x-dev
Component:Code
Category:feature request
Priority:critical
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

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

#1

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

#2

Are there any plans to address this feature request?

#3

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.

#4

Priority:normal» critical

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

#5

Version:6.x-2.x-dev» 6.x-2.0
Status:active» needs review

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);
}
AttachmentSize
resource_conflict.module.datetime.patch 1.28 KB

#6

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

#7

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.

#8

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

#9

Status:needs work» fixed

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

AttachmentSize
344362_datetime_support.patch 1.56 KB

#10

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));

#11

@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?

#12

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.

AttachmentSize
second-datetime.patch 1.11 KB

#13

Status:fixed» closed (fixed)

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

#14

Status:closed (fixed)» needs review

This never got re-opened.

#15

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.

#16

Status:reviewed & tested by the community» fixed

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

#17

Status:fixed» closed (fixed)

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

nobody click here