diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2023-10-31 22:39:22 +0100 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2023-10-31 22:39:47 +0100 |
commit | fd1ff5ad10e530661f59e3218dbf8ea97cfe4112 (patch) | |
tree | 23eee67b061188858a6da705a43b3a186e992400 /lib/Travel/Routing/DE/HAFAS/Utils.pm |
initial commit
Diffstat (limited to 'lib/Travel/Routing/DE/HAFAS/Utils.pm')
-rw-r--r-- | lib/Travel/Routing/DE/HAFAS/Utils.pm | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/Travel/Routing/DE/HAFAS/Utils.pm b/lib/Travel/Routing/DE/HAFAS/Utils.pm new file mode 100644 index 0000000..4b5bdb7 --- /dev/null +++ b/lib/Travel/Routing/DE/HAFAS/Utils.pm @@ -0,0 +1,32 @@ +package Travel::Routing::DE::HAFAS::Utils; + +# vim:foldmethod=marker + +use strict; +use warnings; +use 5.014; + +use parent 'Exporter'; +our @EXPORT = qw(handle_day_change); + +sub handle_day_change { + my (%opt) = @_; + my $datestr = $opt{date}; + my $timestr = $opt{time}; + my $offset_days = 0; + + # timestr may include a day offset, resulting in DDHHMMSS + if ( length($timestr) == 8 ) { + $offset_days = substr( $timestr, 0, 2, q{} ); + } + + my $ts = $opt{strp_obj}->parse_datetime("${datestr}T${timestr}"); + + if ($offset_days) { + $ts->add( days => $offset_days ); + } + + return $ts; +} + +1; |