also handle date from current day, where no date, but only time is given

This commit is contained in:
Matthias Merz 2019-04-25 22:16:33 +02:00
parent a43f2cff1e
commit 1400126804

View File

@ -19,6 +19,7 @@ package Finance::Quote::DKB;
use strict; use strict;
use HTML::TreeBuilder::XPath; use HTML::TreeBuilder::XPath;
use POSIX qw(strftime);
my $agent_string = 'Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0'; my $agent_string = 'Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0';
@ -120,9 +121,12 @@ sub dkb
my @dates = $parser->findnodes( '//div[@class="exchangeLine"]/span'); my @dates = $parser->findnodes( '//div[@class="exchangeLine"]/span');
if (@dates) { if (@dates) {
my $tradedate = $dates[0]->as_text; my $tradedate = $dates[0]->as_text;
$tradedate =~ s/.*(\d\d\.\d\d\.\d\d \d\d:\d\d).*/\1/g; $tradedate =~ s/.*\|\s*(\d\d.*) $/\1/g;
$info{$stock,'date'} = $dates[0]->as_text; if (length($tradedate) < 10) {
$quoter->store_date(\%info, $stock, {eurodate => $dates[0]->as_text}); $tradedate = POSIX::strftime( '%d.%m.%Y', localtime());
}
$info{$stock,'date'} = $tradedate;
$quoter->store_date(\%info, $stock, {eurodate => $tradedate});
}; };
$info{$stock,'timezone'} = 'Europe/Berlin'; $info{$stock,'timezone'} = 'Europe/Berlin';
#$info{$stock,'currency'} = 'EUR'; #$info{$stock,'currency'} = 'EUR';