Discussed in #697842: Support array of values for dates. Here is a patch for the D6 beta-10 version.

I also posted a patch for D7-alpha 3 in #697842: Support array of values for dates

CommentFileSizeAuthor
datearray.patch3.8 KBeiriksm

Comments

mkennedy2d’s picture

Thanks, it works great!

rachelf’s picture

Status: Needs review » Reviewed & tested by the community

Works great for me. Thanks eiriksm!

dave reid’s picture

Version: 6.x-1.0-beta10 » 6.x-1.x-dev
Status: Reviewed & tested by the community » Needs work

Needs to following coding standards, and also have tests to ensure this works properly.

eiriksm’s picture

I would be glad to make the code according to standards and have tests for it, but i am not a programmer by education so especially the tests i have no clue how to make.

but obviously anyone are very welcome to rewrite the code according to standards and make tests to ensure it's working properly. just wanted to share the code that works for me, and that i am using on 3 live sites.

blackdotbug’s picture

Hey all,
Thanks so much for this patch! I was experiencing a bug with it though. For my multivalue date fields, the first start date was getting used for all of them. I updated this function in the FeedsParser.inc file to use the fieldnumber variable and it appears to be fixed. Not sure how to include it in the patch and thought I'd post to get confirmation first that it even should be included.

  /**
   * Helper method for buildDateField(). Build a FeedsDateTimeElement object
   * from a standard formatted node.
   */
  protected static function readDateField($node, $field_name, $fieldnumber=0) {
    $field = content_fields($field_name);
    $ret = new FeedsDateTimeElement();
    if (isset($node->{$field_name}[$fieldnumber]['date']) && $node->{$field_name}[$fieldnumber]['date'] instanceof FeedsDateTime) {
      $ret->start = $node->{$field_name}[$fieldnumber]['date'];
    }
    if (isset($node->{$field_name}[$fieldnumber]['date2']) && $node->{$field_name}[$fieldnumber]['date2'] instanceof FeedsDateTime) {
      $ret->end = $node->{$field_name}[$fieldnumber]['date2'];
    }
    return $ret;
  }

Then I edited the next function where this one is called and passed the fieldnumber variable along. (line 387)

    $oldfield = FeedsDateTimeElement::readDateField($node, $field_name, $fieldnumber);

I'm using the patch with the 6x-1.0-beta13 version and all else appears to be working well.

damienmckenna’s picture

Title: Support array of values for dates (mapping to a date multifield) (D6). Patch included. » Support array of values for dates (mapping to a date multifield)

Simplified the title.

twistor’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)