Currently Date fields do not work with Deploy unless you have a Date type with select fields. This is because Services saves nodes through drupal_execute(), and Date module does not explicitly support this method of saving nodes.

Some more on this issue: #374346: Can't import date values into Date module fields

Comments

gdd’s picture

Note I don't plan on chasing after this for the time being, but if others want to start working on patches feel free.

trebuchet77’s picture

This is the last challenge for our use of Deploy.

There is no combination of "Date type with select fields" that I can get to work. I'm using a test content type with just simple Title/Body and 1 field to test this. I've tried pretty much all of the date formats (I'd like month-day-Year only), with year only, time only, all 6 ,etc. and they all lead to "illegal choice has been detected" error on the receiving server. We are actively using Deploy for many content types that don't have Date fields necessary.

I don't see where the date_deploy.module is ever being used, if that has anything to do with it.

Has anyone actually gotten Date fields to work? A beer or few at SF Drupalcon for any successful advice!

Drupal 6.15, btw.

gdoteof’s picture

This is also a challenge for us. We are looking into using Deploy to go from one source to multiple clients.

I am hoping someone with experience can chime in here with exactly where the problem lies and potential ways to fix or hack around the issue.

Is the problem with the widgets on the Source or the Client end (or both?). For us, if the problem is the Source, then would it be feasible to change all of the widgets on the Source to be the 'acceptable' type, while leaving the Client widgets in place?

gdd’s picture

Status: Active » Closed (won't fix)

Until such a time as there is a good solution I'm marking this won't fix

artt’s picture

trebuchet77,

After spending a whole day to test different combinations. I just found I did the same thing with you. Of course, I got the same results.

I don't have more time and enough knowledge to focus myself on this problem right now, so I decided to cut out the date fields.

Almost 6 months passed since you've tested it.

Pity.

Art

snehi’s picture

I have changed some code in date_deploy module here is the attachment please check it, the date fields in pop up and select list are also working fine on php 5.2. here is the code, this code is also working with date, datetime and datestamp too

<?php
// $Id$
/**
 * Get an array listing the names of all date fields.
 *
 * @return
 *   Array of all created date fields
 **/
function date_deploy_get_date_fields() {
  // This isn't changing much, so cache it to save some queries
  static $date_fields = array();
  if (empty($date_fields)) {
 //davinder   $fields = content_fields();
    $date_types = array('datetime', 'date', 'datestamp');
     $fields = content_fields();

    foreach ($fields as $name => $field) {
      if (in_array($field['type'], $date_types)) {
          $date_fields[$name] = $field;
   }
  }
  }
return $date_fields;
 }
/** modifications by davinder
 */
function date_deploy_rebuild_date($date, $field) {

   $rebuild = array();
   $timezone_db = new DateTimeZone($date['timezone_db']);
   $timezone    = new DateTimeZone($date['timezone']);
    $format      = isset($field['widget']['input_format_custom']) && $field['widget']['input_format_custom'] ? $field['widget']['input_format_custom'] : $field['widget']['input_format'];
   $value['value'] = new DateTime($date['value'], $timezone_db);
   $value['value']->setTimezone($timezone);
    if (isset($date['value2']) ) {
    $value['value2'] = new DateTime($date['value2'], $timezone_db);
     $value['value2']->setTimezone($timezone);
  }
   foreach($value as $key => $datetime) {
    switch ($field['widget']['type']) {
   case 'date_popup':
  $rebuild[$key]['date'] = $datetime->format(date_limit_format($format, array('year', 'month', 'day') ) );
   $rebuild[$key]['time'] = $datetime->format(date_limit_format($format, array('hour', 'minute', 'second') ) );
     break;
    case 'date_select':
     $parts = date_parse($datetime->format($format) );
      $rebuild[$key] = array_intersect_key($parts, array_flip(array('year', 'month', 'day', 'hour', 'minute', 'second') ) );
      $rebuild[$key]['minute'] = str_pad($value['minute'], 2, '0', STR_PAD_LEFT);
       break;
     default:
     $rebuild[$key]['date'] = $datetime->format(date_limit_format($format, $field['granularity']) );
      break;
   }

  }
 return $rebuild;
}

/**
 * Implementation of hook_node_deploy(),
 *
 * @param $node
 *   The node we're deploying.
 * @return
 *   The results of our xmlrpc call.
 *
 * @todo big report with date to avoid the node_lod() below
 */
function date_node_deploy(&$node) {
  // There is a bug somewhere in the FAPI munging in node_deploy() that 
  // causes date values to get trashed. In order to get around this, we
  // actually need to node_load() each node as it comes through in order
  // to retrieve the original date value. !shoot($messenger)
 if(!$original_node = node_load($node->nid)) {
   return;
  }
 // $original_node = node_load($local_nid);
//davinder  $date_fields = date_deploy_get_date_fields();
  
  // The dates need to be saved as $node->field[delta]['value'][part]
  $fields = date_deploy_get_date_fields();

 // foreach ($date_fields as $field_name) {
      foreach ($fields as $field_name => $field) {
    if (property_exists($original_node, $field_name)) {
    //  unset($node->{$field_name});
      foreach ($original_node->{$field_name} as $key => $date_value) {
      //  $date_keys = array('value', 'value2');
      //  foreach($date_keys as $date_key) {

/**        if (!is_null($date_value['value'])) {
          $date_parts = date_parse($date_value['value']);
          $node->{$field_name}[$key]['value']['year'] = $date_parts['year'];
          $node->{$field_name}[$key]['value']['month'] = $date_parts['month'];
          $node->{$field_name}[$key]['value']['day'] = $date_parts['day'];
          $node->{$field_name}[$key]['value']['hour'] = $date_parts['hour'];
          $node->{$field_name}[$key]['value']['minute'] = $date_parts['minute'];
          $node->{$field_name}[$key]['value']['second'] = $date_parts['second'];
       

      }*/
         if (!is_null($date_value['value'])) {
 	      //	$date_parts = date_parse($date_value[$date_key]);
 	     // 	$node->{$field_name}[$key][$date_key]['year'] = $date_parts['year'];
 	     // 	$node->{$field_name}[$key][$date_key]['month'] = $date_parts['month'];
 	     // 	$node->{$field_name}[$key][$date_key]['day'] = $date_parts['day'];
 	     // 	$node->{$field_name}[$key][$date_key]['hour'] = $date_parts['hour'];
 	     // 	$node->{$field_name}[$key][$date_key]['minute'] = $date_parts['minute'];
 	     // 	$node->{$field_name}[$key][$date_key]['second'] = $date_parts['second'];
 	     unset($node->{$field_name});
             $node->{$field_name}[$key] = date_deploy_rebuild_date($date_value, $field);
              }

    }
  } 
}
}