From d0c35146dd9b8b0625eacefb59402a16519b5c5f Mon Sep 17 00:00:00 2001 From: tillcash Date: Sat, 29 Jun 2024 00:21:59 +0530 Subject: [PATCH] [HinduTamilBridge] Fix timestamp again (#4142) --- bridges/HinduTamilBridge.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/bridges/HinduTamilBridge.php b/bridges/HinduTamilBridge.php index cab04171..1b556ed8 100644 --- a/bridges/HinduTamilBridge.php +++ b/bridges/HinduTamilBridge.php @@ -66,7 +66,7 @@ class HinduTamilBridge extends FeedExpander $date = $dom->find('p span.date', 1); if ($date) { - $item['timestamp'] = $date->innertext . ' IST'; + $item['timestamp'] = $this->convertToRFC3339($date->plaintext); } $content = $dom->find('#pgContentPrint', 0); @@ -88,4 +88,16 @@ class HinduTamilBridge extends FeedExpander return $content; } + + private function convertToRFC3339($DateString) + { + $timestamp = strtotime(trim($DateString)); + + if ($timestamp !== false) { + $rfc3339DateTime = date('Y-m-d\TH:i:s', $timestamp) . '+05:30'; + return $rfc3339DateTime; + } else { + return null; + } + } }