aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar sysadminstory <sysadminstory@users.noreply.github.com> 2022-06-07 23:55:15 +0200
committerGravatar GitHub <noreply@github.com> 2022-06-07 23:55:15 +0200
commita4785370fa5ed3c3987fa42010d0fd6db405fbf2 (patch)
tree22b1345b5e64ed03fe6030e66fa6156c22fb196e
parentaa32040bd4849228788d0c4088e9988bb7354406 (diff)
downloadrss-bridge-a4785370fa5ed3c3987fa42010d0fd6db405fbf2.tar.gz
rss-bridge-a4785370fa5ed3c3987fa42010d0fd6db405fbf2.tar.zst
rss-bridge-a4785370fa5ed3c3987fa42010d0fd6db405fbf2.zip
[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).
-rw-r--r--bridges/HotUKDealsBridge.php2
-rw-r--r--bridges/PepperBridgeAbstract.php31
2 files changed, 20 insertions, 13 deletions
diff --git a/bridges/HotUKDealsBridge.php b/bridges/HotUKDealsBridge.php
index ec40bb7b..45cc6637 100644
--- a/bridges/HotUKDealsBridge.php
+++ b/bridges/HotUKDealsBridge.php
@@ -3305,7 +3305,7 @@ class HotUKDealsBridge extends PepperBridgeAbstract {
'th'
),
'local-time-relative' => array(
- 'Found ',
+ 'Posted ',
'm',
'h,',
'day',
diff --git a/bridges/PepperBridgeAbstract.php b/bridges/PepperBridgeAbstract.php
index 5380a7b8..e6e44acd 100644
--- a/bridges/PepperBridgeAbstract.php
+++ b/bridges/PepperBridgeAbstract.php
@@ -119,17 +119,25 @@ class PepperBridgeAbstract extends BridgeAbstract {
. $deal->find('div[class*=' . $selectorHot . ']', 0)
->find('span', 1)->outertext
. '</td></table>';
- $dealDateDiv = $deal->find('div[class*=' . $selectorDate . ']', 0)
- ->find('span[class=hide--toW3]');
- $itemDate = end($dealDateDiv)->plaintext;
- // 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);
+
+ // Check if a clock icon is displayed on the deal
+ $clocks = $deal->find('svg[class*=icon--clock]');
+ if($clocks !== null && count($clocks) > 0) {
+ // Get the last clock, corresponding to the deal posting date
+ $clock = end($clocks);
+
+ // Find the text corresponding to the clock
+ $spanDateDiv = $clock->parent()->find('span[class=hide--toW3]', 0);
+ $itemDate = $spanDateDiv->plaintext;
+ // 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;
}
@@ -564,7 +572,6 @@ HEREDOC;
'year',
''
);
-
$date->modify(str_replace($search, $replace, $str));
return $date->getTimestamp();
}