Received the following error message:

An error occurred. /?q=admin/content/node_import/3/continue
Fatal error: Call to undefined function date_convert_from_custom() in /home/content/u/a/s/uasadmin/html/sites/all/modules/node_import/node_import.inc on line 991

The following is the header and first row of the import file:

Title,Combined,Category,Date,uid
SAP rising in Ulster,"International business software giant SAP is investing a further £900,000 in its Campus-based Engineering Centre (CEC) research facility at Ulster University. Read story.

",News,01/10/2008,Administrator

CommentFileSizeAuthor
#6 node_import.inc_.352446.patch883 bytesobsidiandesign

Comments

Robrecht Jacques’s picture

Have you installed Date API from http://drupal.org/project/date ?

drewmcginty’s picture

Thank you for responding. Yes, I did install Date API and just completed reinstalling it. Still the same problem.

drewmcginty’s picture

Follow up -- issue resolved.

The date in the upload file MUST be in the format "yyyy-mm-dd" and the mask MUST be "Y-m-d"

Robrecht Jacques’s picture

Component: User interface » Documentation
Category: bug » task

This is not true.

Dates in the ISO format (yyyy-mm-dd hh:mm) are always correctly converted.

If you use another format (eg yyyy/mm/dd) you will need to correctly set the "Date input format:" on the "Set import options (step 5 of 8)" page. So if you use "yyyy/mm/dd" you MUST set it to "Y/m/d".

The date input format should probably provide some options such as "/admin/settings/date-time" does.

Robrecht Jacques’s picture

Title: Error on Import » Date input format
obsidiandesign’s picture

Component: Documentation » Code
Category: task » bug
Status: Active » Needs review
StatusFileSize
new883 bytes

In implementing node_import, I discovered the cause of the error
Fatal error: Call to undefined function date_convert_from_custom() in /home/content/u/a/s/uasadmin/html/sites/all/modules/node_import/node_import.inc on line 991
because I too had a problem with a custom date format. The reason for the bug is not that Date API is not installed, but rather that date_convert_from_custom is not actually defined as part of date_api.module - it is included via the date_api_elements.inc file, which is called from hook_elements. This means that, while node_import is checking the date formats, date_convert_from_custom is not actually available, without including the date_api_elements.inc file ourselves.

I've included a patch for review that corrects this error message by ensuring that the date_api_elements.inc file is included. The code is directly from hook_elements() inside the date_api.module file. The patch is made against the 6.x-1.x-dev branch, not the -rc3 downloaded code.

Thanks for the great module - it really saved me time importing content via a custom content type defined via a module (so no CCK).

Bryan O'Shea
Obsidian Design

Robrecht Jacques’s picture

Status: Needs review » Reviewed & tested by the community

Seems you are correct. Strange I didn't get this error while testing custom dates.

Will be included in next release -rc4 as:

module_load_include('inc', 'date_api', 'date_api_elements');

which is the preferred way of including .incs of other modules in 6.x.

Thanks!

snorkers’s picture

As Bryan's patch doesn't work on rc3... (for the impatient) I inserted the following code at line 990 of node_import.inc

  /* date_convert_from_custom is included as part of Date API's hook_elements,
  * so we must include the date_api_elements.inc file directly. */
  require_once('./'. drupal_get_path('module', 'date_api') .'/date_api_elements.inc');

Apologies for being basic, but I haven't sussed out how to generate patch files yet... And thanks Bryan for this - was almost due to give up.

Import worked great - converting a few hundred previously generated news items in an XML/RSS feed into nodes.

Robrecht Jacques’s picture

Status: Reviewed & tested by the community » Fixed

Fixed. Will be included in -rc4. Thanks!

Nash78’s picture

also a lot of thanks!

It worked also! ;)

Status: Fixed » Closed (fixed)

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

astridman’s picture

Version: 6.x-1.0-rc3 » 6.x-1.0-rc4
Status: Closed (fixed) » Active

hate to re-open but....

I have rc4 installed and it absolutely refuses to import any dates into a date_api field. I triple checked that the date format in the CSV is correct: yyyy-mm-dd hh:mm

I tried some non-standard formats, entering in the correct PHP date mask. bupkis.

Also, I tried six ways from sunday to simply have the field filled with the specified default date, but no matter what I do, today's date is always entered.

Robrecht Jacques’s picture

Status: Active » Closed (duplicate)

Could you try the patch #6 from http://drupal.org/node/374346 and report there if you still have problems?

Just copy the file mentionned in comment #6 to sites/all/modules/node_import/supported/date/date.inc (creating a new directory).

Setting it as duplicate.

drupalfan2’s picture

Priority: Normal » Critical
Status: Closed (duplicate) » Active

Date import still does not work.

My date colum has this format
2010-02-03

And I use this format:
Y-m-d

Still not working!!!!!!!!!!

iantresman’s picture

Title: Date input format » Node import: Date input content fields missing

Having installed 6.x-1.0-rc4, I find that I am unable to show a CCK Date field as a Content Field (step 4 of 8). I wasn't sure whether this is due to the format of my date in my input file, but I tried a few different formats. Other CCK fields appears OK, eg. a CCK link field.

Installing 6.x-1.x-dev (2010-Mar-20) fixed the problem, and my added "pubdate" field now appears as expected.

agileadam’s picture

Installing 6.x-1.x-dev made the date fields appear for me as well.

Mat77’s picture

Same as iantresman and keystr0k:

Installing 6.x-1.x-dev made the date fields appear for me as well.

prisonfood’s picture

My own two cents: I did all the above and still couldn't get it to work. I finally thought to add a custom date-time format of type Y-m-d, then select that as the default display for the field on node import options, in order to get my dates to import. Maybe that's obvious to the more experienced users, but it wasn't to me. Also, I hadn't needed to do that in previous date imports.