Created
April 29, 2011 01:59
-
-
Save gugod/947706 to your computer and use it in GitHub Desktop.
Comparison of oral time duration modules
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.012; | |
use strict; | |
use warnings; | |
use utf8; | |
use DateTime; | |
use DateTime::Format::Human::Duration; | |
use Time::Elapsed qw(elapsed); | |
use Time::Duration; | |
my $f = DateTime::Format::Human::Duration->new(); | |
my $now = DateTime->now; | |
for my $seconds qw(0 1 59 60 61 72 3500 3600 3700 86399 86400 86519) { | |
my $dd = $now - $now->clone->subtract(seconds => $seconds); | |
local $, = "\n\t"; | |
say "$seconds second(s):", | |
"Time::Duration: ". duration($seconds), | |
"Time::Elapsed: ". elapsed($seconds), | |
"DTF::Human::Duration: ". $f->format_duration( $dd ); | |
say ""; | |
} |
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
0 second(s): | |
Time::Duration: 0 seconds | |
Time::Elapsed: zero seconds | |
DTF::Human::Duration: no time | |
1 second(s): | |
Time::Duration: 1 second | |
Time::Elapsed: 1 second | |
DTF::Human::Duration: 1 second | |
59 second(s): | |
Time::Duration: 59 seconds | |
Time::Elapsed: 59 seconds | |
DTF::Human::Duration: 59 seconds | |
60 second(s): | |
Time::Duration: 1 minute | |
Time::Elapsed: 1 minute | |
DTF::Human::Duration: 1 minute | |
61 second(s): | |
Time::Duration: 1 minute and 1 second | |
Time::Elapsed: 1 minute and 1 second | |
DTF::Human::Duration: 1 minute and 1 second | |
72 second(s): | |
Time::Duration: 1 minute and 12 seconds | |
Time::Elapsed: 1 minute and 12 seconds | |
DTF::Human::Duration: 1 minute and 12 seconds | |
3500 second(s): | |
Time::Duration: 58 minutes and 20 seconds | |
Time::Elapsed: 58 minutes and 20 seconds | |
DTF::Human::Duration: 58 minutes and 20 seconds | |
3600 second(s): | |
Time::Duration: 1 hour | |
Time::Elapsed: 1 hour | |
DTF::Human::Duration: 1 hour | |
3700 second(s): | |
Time::Duration: 1 hour and 2 minutes | |
Time::Elapsed: 1 hour, 1 minute and 40 seconds | |
DTF::Human::Duration: 1 hour, 1 minute, and 40 seconds | |
86399 second(s): | |
Time::Duration: 1 day | |
Time::Elapsed: 23 hours, 59 minutes and 59 seconds | |
DTF::Human::Duration: 23 hours, 59 minutes, and 59 seconds | |
86400 second(s): | |
Time::Duration: 1 day | |
Time::Elapsed: 1 day | |
DTF::Human::Duration: 1 day | |
86519 second(s): | |
Time::Duration: 1 day and 2 minutes | |
Time::Elapsed: 1 day, 1 minute and 59 seconds | |
DTF::Human::Duration: 1 day, 1 minute, and 59 seconds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment