From 1400126804633bdba6c16ede1885bb786ece899d Mon Sep 17 00:00:00 2001 From: Matthias Merz Date: Thu, 25 Apr 2019 22:16:33 +0200 Subject: [PATCH] also handle date from current day, where no date, but only time is given --- Finance/Quote/DKB.pm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Finance/Quote/DKB.pm b/Finance/Quote/DKB.pm index 7b5b148..bd6ced7 100644 --- a/Finance/Quote/DKB.pm +++ b/Finance/Quote/DKB.pm @@ -19,6 +19,7 @@ package Finance::Quote::DKB; use strict; 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'; @@ -120,9 +121,12 @@ sub dkb my @dates = $parser->findnodes( '//div[@class="exchangeLine"]/span'); if (@dates) { my $tradedate = $dates[0]->as_text; - $tradedate =~ s/.*(\d\d\.\d\d\.\d\d \d\d:\d\d).*/\1/g; - $info{$stock,'date'} = $dates[0]->as_text; - $quoter->store_date(\%info, $stock, {eurodate => $dates[0]->as_text}); + $tradedate =~ s/.*\|\s*(\d\d.*) $/\1/g; + if (length($tradedate) < 10) { + $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,'currency'} = 'EUR';