[YorushikaBridge] Fix getting date (#4077)

* Remove unnecessary variable

* Fix getting date
This commit is contained in:
Miika Launiainen 2024-04-14 20:13:31 +03:00 committed by GitHub
parent 89013faf7d
commit b4d397ff70
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -41,7 +41,6 @@ class YorushikaBridge extends BridgeAbstract
public function collectData() public function collectData()
{ {
$url = 'https://yorushika.com/news/5/';
switch ($this->getInput('lang')) { switch ($this->getInput('lang')) {
case 'jp': case 'jp':
$url = 'https://yorushika.com/news/5/'; $url = 'https://yorushika.com/news/5/';
@ -99,14 +98,8 @@ class YorushikaBridge extends BridgeAbstract
// Get article date // Get article date
$date = $art->find('.date', 0)->plaintext; $date = $art->find('.date', 0)->plaintext;
if (preg_match('/(\d)年(\d)月(\d)/', $date, $matches)) { preg_match('/(\d+)[\.年](\d+)[\.月](\d+)/u', $date, $matches);
// Some dates will contain Chinese characters, remove those from the string $formattedDate = sprintf('%d.%02d.%02d', $matches[1], $matches[2], $matches[3]);
$formattedDate = sprintf('%d.%02d.%02d', $matches[1], $matches[2], $matches[3]);
} else {
// Assume the date is already in 'Y.m.d' format
preg_match('/\d+\.\d+\.\d+/', $date, $matches);
$formattedDate = $matches[0];
}
$date = date_create_from_format('Y.m.d', $formattedDate); $date = date_create_from_format('Y.m.d', $formattedDate);
$date = date_format($date, 'd.m.Y'); $date = date_format($date, 'd.m.Y');