When importing a single year (like 1985) in a date field, the date is considered as a timestamp (because it is numeric) resulting in a date inserted always as 1970 (timestamp 0). The following code in FeedsParser.inc:

if (is_numeric($time)) {
  $time = "@" . $time;
}

should be replaced by:

if (is_numeric($time)) {
      // Make sure it's not a simple year
      if ((is_string($time) && strlen($time) > 4) || is_int($time)) {
        $time = "@" . $time;
      }
    }

Comments

mariagwyn’s picture

having the same problem. Has this been addressed in the code at all? I added the modification above but it did not seem to have an affect. The problem may be that I am entering years like '0409' since I am dealing with historical material. Is there a way to format the date itself that I am missing?

to.stepan.kuzmin@gmail.com’s picture

StatusFileSize
new604 bytes
tekante’s picture

StatusFileSize
new281 bytes

I can confirm the issue exists in the latest code as well and that the patch from #3 resolves the issue. To replicate I set up a date field on a node and used a CSV processor to import 3 records, all with different date formats. One was an epoch time, one was a mm/dd/yyyy string and one was only a year. Before applying the patch the year did not import as desired, after applying the patch and reimporting all three had the desired year.

This patch would prevent anyone from importing unix epoch times with values < 10,000 but I don't see an obvious way in the feeds source to make available an option for picking the input format of the source data. My test data file is attached.

emackn’s picture

Status: Needs review » Fixed

Works well, committed. Thanks!

Status: Fixed » Closed (fixed)

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

dave reid’s picture

Version: 7.x-2.0-alpha4 » 6.x-1.x-dev
Status: Closed (fixed) » Patch (to be ported)

I think this needs to be backported to 6.x-1.x as well?

twistor’s picture

Issue summary: View changes
Status: Patch (to be ported) » Closed (outdated)