summaryrefslogtreecommitdiff
path: root/lib/Travel/Status/DE
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2017-02-14 23:22:33 +0100
committerDaniel Friesel <derf@finalrewind.org>2017-02-14 23:22:33 +0100
commitcec9c94940c35f95cc9333a981725800dbdd3a04 (patch)
tree3e7e4acdf4d89ec8ae18165a0a9040ec5e1559de /lib/Travel/Status/DE
parente37b7d7d4023ec27f2942be3fa4f1cb73531c046 (diff)
sort optimization
Diffstat (limited to 'lib/Travel/Status/DE')
-rw-r--r--lib/Travel/Status/DE/IRIS.pm2
-rw-r--r--lib/Travel/Status/DE/IRIS/Result.pm6
2 files changed, 5 insertions, 3 deletions
diff --git a/lib/Travel/Status/DE/IRIS.pm b/lib/Travel/Status/DE/IRIS.pm
index c805d21..9d7f5ee 100644
--- a/lib/Travel/Status/DE/IRIS.pm
+++ b/lib/Travel/Status/DE/IRIS.pm
@@ -128,7 +128,7 @@ sub new {
} @{ $self->{results} };
@{ $self->{results} }
- = sort { $a->{datetime} <=> $b->{datetime} } @{ $self->{results} };
+ = sort { $a->{epoch} <=> $b->{epoch} } @{ $self->{results} };
# wings (different departures which are coupled as one train) contain
# references to each other. therefore, they must be processed last.
diff --git a/lib/Travel/Status/DE/IRIS/Result.pm b/lib/Travel/Status/DE/IRIS/Result.pm
index 7cc8c7c..96517d9 100644
--- a/lib/Travel/Status/DE/IRIS/Result.pm
+++ b/lib/Travel/Status/DE/IRIS/Result.pm
@@ -153,8 +153,9 @@ sub new {
my $dt = $ref->{datetime} = $dp // $ar;
- $ref->{date} = $dt->strftime('%d.%m.%Y');
- $ref->{time} = $dt->strftime('%H:%M');
+ $ref->{date} = $dt->strftime('%d.%m.%Y');
+ $ref->{time} = $dt->strftime('%H:%M');
+ $ref->{epoch} = $dt->epoch;
$ref->{route_pre} = $ref->{sched_route_pre}
= [ split( qr{[|]}, $ref->{route_pre} // q{} ) ];
@@ -432,6 +433,7 @@ sub merge_with_departure {
# departure is preferred over arrival, so overwrite default values
$self->{date} = $result->{date};
$self->{time} = $result->{time};
+ $self->{epoch} = $result->{epoch};
$self->{datetime} = $result->{datetime};
$self->{train_id} = $result->{train_id};
$self->{train_no} = $result->{train_no};