summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog3
-rwxr-xr-xbin/efa-m10
-rw-r--r--lib/Travel/Status/DE/VRR/Result.pm20
3 files changed, 22 insertions, 11 deletions
diff --git a/Changelog b/Changelog
index eea6fe5..92da526 100644
--- a/Changelog
+++ b/Changelog
@@ -2,6 +2,9 @@ git HEAD
* Add ->key accessor to Travel::Status::DE::VRR::Line
(meaning is unknown)
+ * Add ->is_cancelled accessor to Travel::Status::DE::VRR::Result
+ * Travel::Status::DE::VRR::Result->delay will no longer return '-9999'
+ for cancelled departures, check ->is_cancelled instead
* Allow Travel::Status::DE::VRR::Line and TraveL::Status::DE::VRR::Result
to be serialized to JSON (via TO_JSON method)
diff --git a/bin/efa-m b/bin/efa-m
index a885be3..28136fb 100755
--- a/bin/efa-m
+++ b/bin/efa-m
@@ -136,13 +136,11 @@ sub show_results {
next;
}
+ if ( $d->is_cancelled ) {
+ $dtime .= ' CANCELED';
+ }
if ( $d->delay ) {
- if ($d->delay eq '-9999') {
- $dtime .= ' CANCELED';
- }
- else {
- $dtime .= ' (+' . $d->delay . ')';
- }
+ $dtime .= ' (+' . $d->delay . ')';
}
push( @output,
diff --git a/lib/Travel/Status/DE/VRR/Result.pm b/lib/Travel/Status/DE/VRR/Result.pm
index e1ebee5..0468115 100644
--- a/lib/Travel/Status/DE/VRR/Result.pm
+++ b/lib/Travel/Status/DE/VRR/Result.pm
@@ -9,7 +9,7 @@ use parent 'Class::Accessor';
our $VERSION = '1.03';
Travel::Status::DE::VRR::Result->mk_ro_accessors(
- qw(countdown date delay destination info key line lineref platform
+ qw(countdown date delay destination is_cancelled info key line lineref platform
platform_db sched_date sched_time time type)
);
@@ -18,6 +18,14 @@ sub new {
my $ref = \%conf;
+ if ($ref->{delay} eq '-9999') {
+ $ref->{delay} = 0;
+ $ref->{is_cancelled} = 1;
+ }
+ else {
+ $ref->{is_cancelled} = 0;
+ }
+
return bless( $ref, $obj );
}
@@ -77,10 +85,8 @@ Actual departure date (DD.MM.YYYY).
=item $departure->delay
-Expected delay from scheduled departure time in minutes.
-
-Note that this is only available for DB trains, in other cases it will always
-return 0.
+Expected delay from scheduled departure time in minutes. A delay of 0
+indicates either departure on time or that no delay information is available.
=item $departure->destination
@@ -93,6 +99,10 @@ an address were requested, this is the stop name, otherwise it may be recent
news related to the line's schedule. If no information is available, returns
an empty string.
+=item $departure->is_cancelled
+
+1 if the departure got cancelled, 0 otherwise.
+
=item $departure->key
Unknown. Unlike the name may suggest, this is not a unique key / UUID for a