summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2020-10-04 13:05:06 +0200
committerDaniel Friesel <derf@finalrewind.org>2020-10-04 13:05:06 +0200
commit9ad3b3c9e821c7ef681fd852a728c178ab2685dd (patch)
treeab86a8920d31bd23fa8bc94adbc8ccf5aa37e948 /lib
parentce88fe440c0e39a1bf65d343045b08734e771b72 (diff)
Traewelling can't seem to decide on date formats
Diffstat (limited to 'lib')
-rw-r--r--lib/Travelynx/Helper/Traewelling.pm19
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/Travelynx/Helper/Traewelling.pm b/lib/Travelynx/Helper/Traewelling.pm
index 92a7e88..c7d3ff6 100644
--- a/lib/Travelynx/Helper/Traewelling.pm
+++ b/lib/Travelynx/Helper/Traewelling.pm
@@ -47,18 +47,29 @@ sub get_status_p {
}
else {
if ( my $status = $tx->result->json->{statuses}{data}[0] ) {
- my $strp = DateTime::Format::Strptime->new(
+ my $strp1 = DateTime::Format::Strptime->new(
pattern => '%Y-%m-%dT%H:%M:%S.000000Z',
time_zone => 'UTC',
);
+ my $strp2 = DateTime::Format::Strptime->new(
+ pattern => '%Y-%m-%d %H:%M:%S',
+ time_zone => 'Europe/Berlin',
+ );
my $status_id = $status->{id};
my $message = $status->{body};
my $checkin_at
- = $strp->parse_datetime( $status->{created_at} );
+ = $strp1->parse_datetime( $status->{created_at} )
+ // $strp2->parse_datetime( $status->{created_at} );
- my $dep_dt = $strp->parse_datetime(
+ my $dep_dt
+ = $strp1->parse_datetime(
+ $status->{train_checkin}{departure} )
+ // $strp2->parse_datetime(
$status->{train_checkin}{departure} );
- my $arr_dt = $strp->parse_datetime(
+ my $arr_dt
+ = $strp1->parse_datetime(
+ $status->{train_checkin}{arrival} )
+ // $strp2->parse_datetime(
$status->{train_checkin}{arrival} );
my $dep_eva