Posted by kenorb on December 8, 2008 at 4:17pm
| 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
#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
I would have expected this behaviour (not supporting datetime) I too think it is a must have.
So +1
#5
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);
}
#6
Forgot to mention that i tested it with my datetime field and it worked as expected :-)
#7
Thanks redben for the patch. A few notes:
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
Thanks FiNeX for the testing. I've fixed the code style and committed this to CVS.
#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 conflictforeach ($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.
#13
Automatically closed -- issue fixed for 2 weeks with no activity.
#14
This never got re-opened.
#15
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
I've committed the patch in #12, along with some whitespace code style fixes.
#17
Automatically closed -- issue fixed for 2 weeks with no activity.