summaryrefslogtreecommitdiff
path: root/lib/Travel/Status
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2016-10-06 16:57:54 +0200
committerDaniel Friesel <derf@finalrewind.org>2016-10-06 16:57:54 +0200
commit3606527d76149fe59af960b7e2ab1d37a4be74f3 (patch)
treeaba5855c4e4179b9b2640b3b0459d7206cd14912 /lib/Travel/Status
parent4a40e7ebdd84126278662dbaaa787e9864ab75c9 (diff)
Use the same DateTime::Format::Strptime object for all Result objects
Diffstat (limited to 'lib/Travel/Status')
-rw-r--r--lib/Travel/Status/DE/IRIS.pm23
-rw-r--r--lib/Travel/Status/DE/IRIS/Result.pm2
2 files changed, 16 insertions, 9 deletions
diff --git a/lib/Travel/Status/DE/IRIS.pm b/lib/Travel/Status/DE/IRIS.pm
index 5674d61..e8a39c6 100644
--- a/lib/Travel/Status/DE/IRIS.pm
+++ b/lib/Travel/Status/DE/IRIS.pm
@@ -10,6 +10,7 @@ our $VERSION = '1.10';
use Carp qw(confess cluck);
use DateTime;
+use DateTime::Format::Strptime;
use Encode qw(encode decode);
use List::Util qw(first);
use List::MoreUtils qw(uniq);
@@ -42,6 +43,11 @@ sub new {
user_agent => $ua,
with_related => $opt{with_related},
departure_by_id => {},
+ strptime_obj => DateTime::Format::Strptime->new(
+ pattern => '%y%m%d%H%M',
+ time_zone => 'Europe/Berlin',
+ ),
+
};
bless( $self, $class );
@@ -250,14 +256,15 @@ sub add_result {
}
my %data = (
- raw_id => $id,
- classes => $e_tl->getAttribute('f'), # D N S F
- unknown_t => $e_tl->getAttribute('t'), # p
- train_no => $e_tl->getAttribute('n'), # dep number
- type => $e_tl->getAttribute('c'), # S/ICE/ERB/...
- line_no => $e_tl->getAttribute('l'), # 1 -> S1, ...
- station => $station,
- unknown_o => $e_tl->getAttribute('o'), # owner: 03/80/R2/...
+ raw_id => $id,
+ classes => $e_tl->getAttribute('f'), # D N S F
+ unknown_t => $e_tl->getAttribute('t'), # p
+ train_no => $e_tl->getAttribute('n'), # dep number
+ type => $e_tl->getAttribute('c'), # S/ICE/ERB/...
+ line_no => $e_tl->getAttribute('l'), # 1 -> S1, ...
+ station => $station,
+ unknown_o => $e_tl->getAttribute('o'), # owner: 03/80/R2/...
+ strptime_obj => $self->{strptime_obj},
);
if ($e_ar) {
diff --git a/lib/Travel/Status/DE/IRIS/Result.pm b/lib/Travel/Status/DE/IRIS/Result.pm
index 658eb28..b0bbb29 100644
--- a/lib/Travel/Status/DE/IRIS/Result.pm
+++ b/lib/Travel/Status/DE/IRIS/Result.pm
@@ -116,7 +116,7 @@ sub new {
bless( $ref, $obj );
- $ref->{strptime_obj} = DateTime::Format::Strptime->new(
+ $ref->{strptime_obj} //= DateTime::Format::Strptime->new(
pattern => '%y%m%d%H%M',
time_zone => 'Europe/Berlin',
);