From b244c044be62e39c19125e18e467de19f0ea84fe Mon Sep 17 00:00:00 2001 From: thijsvdanker <thijsvdanker@234472.no-reply.drupal.org> Date: Thu, 23 Apr 2015 10:33:38 -0700 Subject: [PATCH] Issue #1058424 by thijsvdanker: Port date mapper patch to d7 version to support dates before 13 Dec 1901 --- plugins/FeedsParser.inc | 2 +- tests/feeds_date_time.test | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/FeedsParser.inc b/plugins/FeedsParser.inc index 11326203..c864f291 100644 --- a/plugins/FeedsParser.inc +++ b/plugins/FeedsParser.inc @@ -610,7 +610,7 @@ class FeedsDateTime extends DateTime { $time = str_replace("GMT+", "+", $time); // Some PHP 5.2 version's DateTime class chokes on invalid dates. - if (!strtotime($time)) { + if (!date_create($time)) { $time = 'now'; } diff --git a/tests/feeds_date_time.test b/tests/feeds_date_time.test index 8ced8438..989179df 100644 --- a/tests/feeds_date_time.test +++ b/tests/feeds_date_time.test @@ -43,6 +43,11 @@ class FeedsDateTimeTest extends FeedsWebTestCase { $date1 = new FeedsDateTime(2012); $date2 = new FeedsDateTime('January 2012'); $this->assertEqual($date1->format('U'), $date2->format('U')); + + // Check that years before 1902 work correctly. + $early_date_string = '01/02/1901'; + $date = new FeedsDateTime($early_date_string); + $this->assertEqual($date->format('m/d/Y'), $early_date_string); } } -- GitLab