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