I try to import csv file with different date formats:
2010-07-21
2010-07-21 20:23:12 +0000
2010-07-21 T 20:23 UTC
Wed Jul 21 20:23:12 2010
Wed, 21 Jul 2010 20:23:12 +0000

The result always is - Thu, 1970-01-01 00:00

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alex_b’s picture

What do you map the date to? node published date? a CCK date field?

ANT0NI0’s picture

node published date

alex_b’s picture

Title: CSV import problems with Published date » Convert dates mapped to node created or updated.
Version: 6.x-1.0-beta3 » 6.x-1.x-dev
Category: support » feature
Issue tags: +Novice

Thanks for the update - that explains it. There is no date conversion on the node created/updated date mapping targets. We should use FeedsDateTime() for conversion if incoming date is not a UNIX timestamp in FeedsNodeProcessor::setTargetElement().

This is a feature request.

alex_b’s picture

For the record, there are conversion problems with *some* dates, I have just requested that they be fixed on a level that benefits any date handling: #831470-13: Import fails due to dates not converted correctly.

alex_b’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Active » Patch (to be ported)

This is implemented in Drupal 7 now.

These patches need to be backported to Drupal 6 for supporting conversion of dates mapped to created or updated.

http://github.com/lxbarth/Feeds/commit/d0b1283b50bef34ea7047bcb62cc9ac24...

+

http://github.com/lxbarth/Feeds/commit/c349d8131534bca44db3c58923e2e1479...

alex_b’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev
Toxid’s picture

Status: Patch (to be ported) » Needs review

I have no experience in backporting, but I believe I did it successfully since I get no errors on import. However, it did not solve the date problem, it becomes 1970-01-01 00:00.

Toxid’s picture

Status: Needs review » Needs work
FileSize
1.45 KB
wojtha’s picture

Subscribing

Toxid’s picture

The problem for me was not feeds module, it was that the feeds_youtube plugin. Everything works fine for me now.

gaele’s picture

Version: 6.x-1.x-dev » 6.x-1.0-beta10
Status: Needs work » Needs review
FileSize
1.63 KB

case 'body' was forgotten in #8.

Also $target_node->created instead of $value->created in second if clause (error in second patch from #5).

BrockBoland’s picture

FileSize
1.62 KB

Having the same issue: the date field in the feed is in the format "Thu, 05 May 2011 17:31:38 UTC" and isn't being converted to a timestamp for the node created value.

I used the patch from #11 but found I had to tweak it a bit: $value->getValue() returns a FeedsDateTime object, but $node->created needs to be set to a Unix timestamp. Since the FeedsDateTime class defines __toString, I replaced it with this:

$target_node->created = (string)$value;

japanitrat’s picture

Status: Needs work » Needs review

i dont know if this is directly related to this issue, but i tried #12 and it doesn't work on google-reader atom feeds where published-dates have the format "2011-05-21T13:01:52Z".

the imported nodes (from xml-file in atom format) have the current date, not the one from atom-feed.

[EDIT]

Ah, i just saw, that the default node-importer node-mapping has the published-source wrong ("published" whereas "Published date" is available in the dropdown only)

Status: Needs review » Needs work

The last submitted patch, 860942-12.patch, failed testing.

Jim Kirkpatrick’s picture

Status: Needs review » Needs work

It's worth pointing out this is related to #1027020: ATOM parser not getting 'updated' date from Ning feeds as sometimes there's only an 'updated' field for dates in feeds, not the standard 'published' or 'issued'.

kpastore’s picture

Fortunately, I was able to use the patch in #12 successfully to import the correct datetime for my nodes, even though it failed testing (comment #14).

twistor’s picture

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