summaryrefslogtreecommitdiff
path: root/lib/Travel/Routing/DE/HAFAS/Utils.pm
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2024-04-02 17:04:25 +0200
committerBirte Kristina Friesel <derf@finalrewind.org>2024-04-02 17:04:25 +0200
commitf40128dedfd431e91960e1271f1a677369941058 (patch)
tree4014d4f069e836349d751f9702b36f0de7322945 /lib/Travel/Routing/DE/HAFAS/Utils.pm
parente6480f632d07b30f4f3ee538731f157c922a16b2 (diff)
Convert non-local timestamps to local time zone
Diffstat (limited to 'lib/Travel/Routing/DE/HAFAS/Utils.pm')
-rw-r--r--lib/Travel/Routing/DE/HAFAS/Utils.pm10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Travel/Routing/DE/HAFAS/Utils.pm b/lib/Travel/Routing/DE/HAFAS/Utils.pm
index 5b26555..45ee5db 100644
--- a/lib/Travel/Routing/DE/HAFAS/Utils.pm
+++ b/lib/Travel/Routing/DE/HAFAS/Utils.pm
@@ -13,8 +13,13 @@ sub handle_day_change {
my (%opt) = @_;
my $datestr = $opt{date};
my $timestr = $opt{time};
+ my $tz_offset = $opt{offset};
my $offset_days = 0;
+ if ( not defined $timestr ) {
+ return;
+ }
+
# timestr may include a day offset, resulting in DDHHMMSS
if ( length($timestr) == 8 ) {
$offset_days = substr( $timestr, 0, 2, q{} );
@@ -26,6 +31,11 @@ sub handle_day_change {
$ts->add( days => $offset_days );
}
+ if ( defined $tz_offset and $tz_offset != $ts->offset / 60 ) {
+ my $ts_offset = $tz_offset - $ts->offset / 60;
+ $ts->subtract( minutes => $ts_offset );
+ }
+
return $ts;
}