Created
October 4, 2011 02:26
-
-
Save sartak/1260768 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use 5.14.0; | |
use DateTime; | |
use DateTime::Format::Duration; | |
my $depart = DateTime->new( | |
time_zone => "America/New_York", | |
year => 2011, | |
month => 10, | |
day => 4, | |
hour => 8, | |
minute => 10, | |
second => 0, | |
); | |
my $arrive = DateTime->new( | |
time_zone => "Asia/Tokyo", | |
year => 2011, | |
month => 10, | |
day => 5, | |
hour => 11, | |
minute => 0, | |
second => 0, | |
); | |
say DateTime::Format::Duration->new(pattern => '%H hours, %M minutes, %S seconds')->format_duration( | |
$arrive - $depart | |
); | |
# 00 hours, 830 minutes, 00 seconds | |
$depart = DateTime->new( | |
time_zone => "Asia/Tokyo", | |
year => 2011, | |
month => 10, | |
day => 18, | |
hour => 6, | |
minute => 10, | |
second => 0, | |
); | |
$arrive = DateTime->new( | |
time_zone => "America/Chicago", | |
year => 2011, | |
month => 10, | |
day => 18, | |
hour => 3, | |
minute => 35, | |
second => 0, | |
); | |
say DateTime::Format::Duration->new(pattern => '%H hours, %M minutes, %S seconds')->format_duration( | |
$arrive - $depart | |
); | |
# 00 hours, 685 minutes, 00 seconds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment