Unverified Commit 748aec53 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Rename {arr,dep}_datetime to {arr,dep}

This is consistent with the naming of sched_{arr,dep} and rt_{arr,dep} as well
ase the accessors of Travel::Status::DE::HAFAS::Stop
parent 4c4be277
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -332,7 +332,7 @@ for my $res ( $hafas->connections ) {
				"%-5s %-${have_delay}s ab  %s%s%s\n",
				$sec->dep_cancelled
				? '--:--'
				: $sec->dep_datetime->strftime('%H:%M'),
				: $sec->dep->strftime('%H:%M'),
				format_delay( $sec->dep_delay ),
				$sec->dep_loc->name,
				$sec->dep_platform ? q{: } : q{},
@@ -342,7 +342,7 @@ for my $res ( $hafas->connections ) {
				"%-5s %-${have_delay}s an  %s%s%s\n",
				$sec->arr_cancelled
				? '--:--'
				: $sec->arr_datetime->strftime('%H:%M'),
				: $sec->arr->strftime('%H:%M'),
				format_delay( $sec->arr_delay ),
				$sec->arr_loc->name,
				$sec->arr_platform ? q{: } : q{},
+2 −2
Original line number Diff line number Diff line
@@ -648,9 +648,9 @@ Travel::Routing::DE::HAFAS - Interface to HAFAS itinerary services
			if ( $sec->type eq 'JNY' ) {
				printf("%s -> %s\n%s ab %s\n%s an %s\n\n",
					$sec->name, $sec->direction,
					$sec->dep_datetime->strftime('%H:%M'),
					$sec->dep->strftime('%H:%M'),
					$sec->dep_loc->name,
					$sec->arr_datetime->strftime('%H:%M'),
					$sec->arr->strftime('%H:%M'),
					$sec->arr_loc->name,
				);
			}
+5 −5
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@ use Travel::Routing::DE::HAFAS::Connection::Section;
our $VERSION = '0.00';

Travel::Routing::DE::HAFAS::Connection->mk_ro_accessors(
	qw(changes duration sched_dep rt_dep sched_arr rt_arr dep_datetime arr_datetime dep_platform arr_platform dep_loc arr_loc dep_cancelled arr_cancelled is_cancelled load)
	qw(changes duration sched_dep rt_dep sched_arr rt_arr dep arr dep_platform arr_platform dep_loc arr_loc dep_cancelled arr_cancelled is_cancelled load)
);

# {{{ Constructor
@@ -119,8 +119,8 @@ sub new {
		dep_cancelled => $dep_cancelled,
		arr_cancelled => $arr_cancelled,
		is_cancelled  => $is_cancelled,
		dep_datetime  => $rt_dep // $sched_dep,
		arr_datetime  => $rt_arr // $sched_arr,
		dep           => $rt_dep // $sched_dep,
		arr           => $rt_arr // $sched_arr,
		dep_platform  => $connection->{dep}{dPlatfR}
		  // $connection->{dep}{dPlatfS},
		arr_platform => $connection->{arr}{aPlatfR}
@@ -201,7 +201,7 @@ individual parts of the connection.
True if the arrival of the last section in this connection has been cancelled,
false otherwise.

=item $connection->arr_datetime
=item $connection->arr

DateTime(3pm) object holding the arrival time and date. Based on real-time data
if available, falls back to schedule data otherwise.
@@ -223,7 +223,7 @@ Number of changes between different modes of transport.
True if the departure of the first section in this connection has been
cancelled, false otherwise.

=item $connection->dep_datetime
=item $connection->dep

DateTime(3pm) object holding the departure time and date. Based on real-time
data if available, falls back to schedule data otherwise.
+17 −9
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ use Travel::Routing::DE::HAFAS::Utils;
our $VERSION = '0.00';

Travel::Routing::DE::HAFAS::Connection::Section->mk_ro_accessors(
	qw(type schep_dep rt_dep sched_arr rt_arr dep_datetime arr_datetime arr_delay dep_delay journey distance duration transfer_duration dep_loc arr_loc
	qw(type schep_dep rt_dep sched_arr rt_arr dep arr arr_delay dep_delay journey distance duration transfer_duration dep_loc arr_loc
	  dep_platform arr_platform dep_cancelled arr_cancelled
	  operator id name category category_long class number line line_no load delay direction)
);
@@ -72,14 +72,17 @@ sub new {
		}
	}

	# TODO load
	# TODO operator

	my $ref = {
		type          => $sec->{type},
		sched_dep     => $sched_dep,
		rt_dep        => $rt_dep,
		sched_arr     => $sched_arr,
		rt_arr        => $rt_arr,
		dep_datetime  => $rt_dep // $sched_dep,
		arr_datetime  => $rt_arr // $sched_arr,
		dep           => $rt_dep // $sched_dep,
		arr           => $rt_arr // $sched_arr,
		dep_loc       => $locs->[ $sec->{dep}{locX} ],
		arr_loc       => $locs->[ $sec->{arr}{locX} ],
		dep_platform  => $sec->{dep}{dplatfR} // $sec->{dep}{dPlatfS},
@@ -99,7 +102,6 @@ sub new {

	if ( $sec->{type} eq 'JNY' ) {

		#operator id name type type_long class number line line_no load delay direction)
		my $journey = $sec->{jny};
		my $product = $prodL[ $journey->{prodX} ];
		$ref->{id}            = $journey->{jid};
@@ -119,6 +121,12 @@ sub new {
		{
			$ref->{name} .= ' ' . $product->{nameS};
		}

		my @stops;
		for my $stop ( @{ $journey->{stopL} // [] } ) {
			my $loc = $locs->[ $stop->{locX} ];
			say $loc->name;
		}
	}
	elsif ( $sec->{type} eq 'WALK' ) {
		$ref->{distance} = $sec->{gis}{dist};
@@ -142,7 +150,7 @@ sub new {
sub set_transfer_from_previous_section {
	my ( $self, $prev_sec ) = @_;

	my $delta = $self->dep_datetime - $prev_sec->arr_datetime;
	my $delta = $self->dep - $prev_sec->arr;
	$self->{transfer_duration} = $delta;
}

@@ -175,9 +183,9 @@ Travel::Routing::DE::HAFAS::Connection::Section - A single trip between two stop
	for my $sec ( $connection->sections ) {
		printf("%s -> %s\n%s ab %s\n%s an %s\n\n",
			$sec->name, $sec->direction,
			$sec->dep_datetime->strftime('%H:%M'),
			$sec->dep->strftime('%H:%M'),
			$sec->dep_loc->name,
			$sec->arr_datetime->strftime('%H:%M'),
			$sec->arr->strftime('%H:%M'),
			$sec->arr_loc->name,
		);
	}
@@ -207,7 +215,7 @@ in which they are valid and return undef when called in other contexts.
True if the arrival at the end of this section has been cancelled.
False otherwise.

=item $section->arr_datetime
=item $section->arr

DateTime(3pm) object holding the arrival time and date. Based on real-time data
if available, falls back to schedule data otherwise.
@@ -229,7 +237,7 @@ Arrival platform as string, not necessarily numeric. Undef if unknown.
True if the departure at the start of this section has been cancelled.
False otherwise.

=item $section->dep_datetime
=item $section->dep

DateTime(3pm) object holding the departure time and date. Based on real-time
data if available, falls back to schedule data otherwise.