[DealabsBridge-HotUKDealsBridge-MydealsBridge-PepperBridgeAbstract] Fix (#2789)

the date handling

The deal posting date logic was wrong, and leaded to warnings and
notice. Now, only the feed with the deal sorted by date contains date
(the feed sorted by hottest deal does not contain a date anymore,
because there are no deal date in this case).
This commit is contained in:
sysadminstory 2022-06-07 23:55:15 +02:00 committed by GitHub
parent aa32040bd4
commit a4785370fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 13 deletions

View File

@ -3305,7 +3305,7 @@ class HotUKDealsBridge extends PepperBridgeAbstract {
'th' 'th'
), ),
'local-time-relative' => array( 'local-time-relative' => array(
'Found ', 'Posted ',
'm', 'm',
'h,', 'h,',
'day', 'day',

View File

@ -119,17 +119,25 @@ class PepperBridgeAbstract extends BridgeAbstract {
. $deal->find('div[class*=' . $selectorHot . ']', 0) . $deal->find('div[class*=' . $selectorHot . ']', 0)
->find('span', 1)->outertext ->find('span', 1)->outertext
. '</td></table>'; . '</td></table>';
$dealDateDiv = $deal->find('div[class*=' . $selectorDate . ']', 0)
->find('span[class=hide--toW3]'); // Check if a clock icon is displayed on the deal
$itemDate = end($dealDateDiv)->plaintext; $clocks = $deal->find('svg[class*=icon--clock]');
// In case of a Local deal, there is no date, but we can use if($clocks !== null && count($clocks) > 0) {
// this case for other reason (like date not in the last field) // Get the last clock, corresponding to the deal posting date
if ($this->contains($itemDate, $this->i8n('localdeal'))) { $clock = end($clocks);
$item['timestamp'] = time();
} else if ($this->contains($itemDate, $this->i8n('relative-date-indicator'))) { // Find the text corresponding to the clock
$item['timestamp'] = $this->relativeDateToTimestamp($itemDate); $spanDateDiv = $clock->parent()->find('span[class=hide--toW3]', 0);
} else { $itemDate = $spanDateDiv->plaintext;
$item['timestamp'] = $this->parseDate($itemDate); // In case of a Local deal, there is no date, but we can use
// this case for other reason (like date not in the last field)
if ($this->contains($itemDate, $this->i8n('localdeal'))) {
$item['timestamp'] = time();
} else if ($this->contains($itemDate, $this->i8n('relative-date-indicator'))) {
$item['timestamp'] = $this->relativeDateToTimestamp($itemDate);
} else {
$item['timestamp'] = $this->parseDate($itemDate);
}
} }
$this->items[] = $item; $this->items[] = $item;
} }
@ -564,7 +572,6 @@ HEREDOC;
'year', 'year',
'' ''
); );
$date->modify(str_replace($search, $replace, $str)); $date->modify(str_replace($search, $replace, $str));
return $date->getTimestamp(); return $date->getTimestamp();
} }