Skip to content

Commit

Permalink
Import of MSTRAT/DateTime-Format-Human-Duration-0.4 from CPAN.
Browse files Browse the repository at this point in the history
gitpan-cpan-distribution: DateTime-Format-Human-Duration
gitpan-cpan-version:      0.4
gitpan-cpan-path:         MSTRAT/DateTime-Format-Human-Duration-0.4.tar.gz
gitpan-cpan-author:       MSTRAT
gitpan-cpan-maturity:     released
  • Loading branch information
mstratman authored and Gitpan committed Oct 21, 2014
1 parent 5d6b4c2 commit 358acf9
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 27 deletions.
6 changes: 4 additions & 2 deletions Build.PL
Expand Up @@ -7,10 +7,12 @@ my $builder = Module::Build->new(
license => 'perl',
dist_author => 'Daniel Muey <http://drmuey.com/cpan_contact.pl>',
dist_version_from => 'lib/DateTime/Format/Human/Duration.pm',
requires => {
build_requires => {
'Test::More' => 0,
'version' => 0,
'File::Spec' => 0,
'FindBin' => 0,
},
requires => { },
add_to_cleanup => [ 'DateTime-Format-Human-Duration-*' ],
);

Expand Down
6 changes: 6 additions & 0 deletions Changes
@@ -1,5 +1,11 @@
Revision history for DateTime-Format-Human-Duration

0.4 Wed Apr 11 21:46:08 CDT 2012
* Simplified version number scheme to ordinary decimal.
* Minor POD changes
* Fixed 02.array.t (hopefully) to actually use nb.pm and to
pass when DateTime is not installed.

0.0.3 Tue Apr 10 20:37:18 CDT 2012
* Updated manifest - 0.0.2 was missing some needed files. Big whoops!

Expand Down
1 change: 1 addition & 0 deletions MANIFEST
Expand Up @@ -13,6 +13,7 @@ README
t/00.load.t
t/01.methods.t
t/02.array.t
t/lib/DateTime/Format/Human/Duration/Locale/nb.pm
t/nb.pm
t/perlcritic.t
t/pod-coverage.t
Expand Down
11 changes: 5 additions & 6 deletions META.json
Expand Up @@ -22,7 +22,9 @@
"prereqs" : {
"build" : {
"requires" : {
"ExtUtils::MakeMaker" : 0
"File::Spec" : 0,
"FindBin" : 0,
"Test::More" : 0
}
},
"configure" : {
Expand All @@ -31,10 +33,7 @@
}
},
"runtime" : {
"requires" : {
"Test::More" : 0,
"version" : 0
}
"requires" : {}
}
},
"release_status" : "stable",
Expand All @@ -43,5 +42,5 @@
"url" : "https://github.com/mstratman/DateTime-Format-Human-Duration"
}
},
"version" : "v0.0.3"
"version" : "0.4"
}
10 changes: 5 additions & 5 deletions META.yml
Expand Up @@ -3,7 +3,9 @@ abstract: 'Get a locale specific string describing the span of a given duration'
author:
- 'Daniel Muey <http://drmuey.com/cpan_contact.pl>'
build_requires:
ExtUtils::MakeMaker: 0
File::Spec: 0
FindBin: 0
Test::More: 0
configure_requires:
ExtUtils::MakeMaker: 0
dynamic_config: 1
Expand All @@ -17,9 +19,7 @@ no_index:
directory:
- t
- inc
requires:
Test::More: 0
version: 0
requires: {}
resources:
repository: https://github.com/mstratman/DateTime-Format-Human-Duration
version: v0.0.3
version: 0.4
6 changes: 4 additions & 2 deletions Makefile.PL
Expand Up @@ -8,10 +8,12 @@ WriteMakefile(
VERSION_FROM => 'lib/DateTime/Format/Human/Duration.pm',
ABSTRACT_FROM => 'lib/DateTime/Format/Human/Duration.pm',
PL_FILES => {},
PREREQ_PM => {
BUILD_REQUIRES => {
'Test::More' => 0,
'version' => 0,
'File::Spec' => 0,
'FindBin' => 0,
},
PREREQ_PM => { },
META_MERGE => {
resources => {
repository => 'https://github.com/mstratman/DateTime-Format-Human-Duration',
Expand Down
9 changes: 3 additions & 6 deletions lib/DateTime/Format/Human/Duration.pm
Expand Up @@ -4,7 +4,7 @@ use warnings;
use strict;
require DateTime::Format::Human::Duration::Locale;

use version; our $VERSION = qv('0.0.3');
our $VERSION = '0.4';

sub new {
bless { 'locale_cache' => {} }, 'DateTime::Format::Human::Duration';
Expand Down Expand Up @@ -124,10 +124,6 @@ __END__
DateTime::Format::Human::Duration - Get a locale specific string describing the span of a given duration
=head1 VERSION
This document describes DateTime::Format::Human::Duration version 0.0.1
=head1 SYNOPSIS
use DateTime;
Expand Down Expand Up @@ -226,7 +222,8 @@ This facilitates, for example, this L<Locale::Maketext> vernacular which becomes
Localization is provided by the included DateTime::Format::Human::Duration::Locale modules.
Included are DateTime::Format::Human::Duration::Locale::es, DateTime::Format::Human::Duration::Locale::fr, DateTime::Format::Human::Duration::Locale::pt
Included are DateTime::Format::Human::Duration::Locale::es, DateTime::Format::Human::Duration::Locale::fr, DateTime::Format::Human::Duration::Locale::pt,
DateTime::Format::Human::Duration::Locale::de
More will be included as time permits/folks volunteer/CLDR becomes an option
Expand Down
18 changes: 12 additions & 6 deletions t/02.array.t
@@ -1,17 +1,23 @@
use Test::More;
use lib 't/lib';
use DateTime::Format::Human::Duration;
use DateTime;


my $dta = DateTime->now( locale => 'nb' );
my $dtb = $dta->clone->add( minutes => 1 );
my $dtc = $dta->clone->subtract( minutes => 1 );
use FindBin qw($Bin);
use File::Spec;
BEGIN { push @INC, File::Spec->catfile($Bin, 'lib'); }


my $fmt = DateTime::Format::Human::Duration->new;

ok(1, "placeholder");
TODO: {
# Hrm... can you skip in a TODO?
eval 'use DateTime';
last TODO if $@;

my $dta = DateTime->now( locale => 'nb' );
my $dtb = $dta->clone->add( minutes => 1 );
my $dtc = $dta->clone->subtract( minutes => 1 );

local $TODO = "See outstanding RT issue #74923: https://rt.cpan.org/Public/Bug/Display.html?id=74923";
is($fmt->format_duration_between($dta, $dtb, past => '%s ago', future => 'in %s'),
'in 1mi');
Expand Down
24 changes: 24 additions & 0 deletions t/lib/DateTime/Format/Human/Duration/Locale/nb.pm
@@ -0,0 +1,24 @@
package DateTime::Format::Human::Duration::Locale::nb;
# XXX: this isn't really NB locale, I just cheat the system.
#
sub get_human_span_from_units_array {
my ($years, $months, $weeks, $days, $hours, $minutes, $seconds, $nanoseconds, $args_hr) = @_; # note: has no negative numbers
if ($years) {
$s = $years . "y";
} elsif ($months) {
$s = $months . "mo";
} elsif ($weeks) {
$s = $weeks . "w";
} elsif ($days) {
$s = $days . "d";
} elsif ($hours) {
$s = $hours . "h";
} elsif ($minutes) {
$s = $minutes . "mi";
} elsif ($seconds) {
$s = "moments";
}
return $s;
}

1;

0 comments on commit 358acf9

Please sign in to comment.