r6062 - in /branches/upstream/libtime-human-perl: ./ current/ current/Changes current/Human.pm current/MANIFEST current/META.yml current/Makefile.PL current/test.pl
joeyh at users.alioth.debian.org
joeyh at users.alioth.debian.org
Mon Jul 30 05:25:06 UTC 2007
Author: joeyh
Date: Mon Jul 30 05:25:06 2007
New Revision: 6062
URL: http://svn.debian.org/wsvn/?sc=1&rev=6062
Log:
[svn-inject] Installing original source of libtime-human-perl
Added:
branches/upstream/libtime-human-perl/
branches/upstream/libtime-human-perl/current/
branches/upstream/libtime-human-perl/current/Changes
branches/upstream/libtime-human-perl/current/Human.pm
branches/upstream/libtime-human-perl/current/MANIFEST
branches/upstream/libtime-human-perl/current/META.yml
branches/upstream/libtime-human-perl/current/Makefile.PL
branches/upstream/libtime-human-perl/current/test.pl
Added: branches/upstream/libtime-human-perl/current/Changes
URL: http://svn.debian.org/wsvn/branches/upstream/libtime-human-perl/current/Changes?rev=6062&op=file
==============================================================================
--- branches/upstream/libtime-human-perl/current/Changes (added)
+++ branches/upstream/libtime-human-perl/current/Changes Mon Jul 30 05:25:06 2007
@@ -1,0 +1,10 @@
+Revision history for Perl extension Time::Human.
+
+1.03 Wed Jan 10 15:38:11 HST 2007
+ - applied a one line to trim whitespace in the output, from Ricardo SIGNES
+ - misc. doc cleanups
+
+0.01 Thu Mar 1 21:27:47 2001
+ - original version; created by h2xs 1.20 with options
+ -XA -n Time::Human
+
Added: branches/upstream/libtime-human-perl/current/Human.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libtime-human-perl/current/Human.pm?rev=6062&op=file
==============================================================================
--- branches/upstream/libtime-human-perl/current/Human.pm (added)
+++ branches/upstream/libtime-human-perl/current/Human.pm Mon Jul 30 05:25:06 2007
@@ -1,0 +1,172 @@
+package Time::Human;
+
+require 5.005_62;
+use strict;
+use warnings;
+
+require Exporter;
+
+our @ISA = qw(Exporter);
+
+# Items to export into callers namespace by default. Note: do not export
+# names by default without a very good reason. Use EXPORT_OK instead.
+# Do not simply export all your public functions/methods/constants.
+
+# This allows declaration use Time::Human ':all';
+# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
+# will save memory.
+our %EXPORT_TAGS = ( 'all' => [ qw(
+ humantime
+) ] );
+
+our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
+
+our @EXPORT = qw(
+ humanize
+
+);
+our $VERSION = '1.03';
+
+our %templates = (
+
+ English => {
+ numbers => [ qw(one two three four five six seven eight nine ten eleven twelve) ],
+ vagueness=> [ "exactly", "just after", "a little after", "coming up to", "almost"],
+ daytime => [ "in the morning", "in the afternoon", "in the evening", "at night" ],
+ minutes => ["five past", "ten past", "quarter past", "twenty past",
+ "twenty-five past", "half past", "twenty-five to",
+ "twenty to", "quarter to", "ten to", "five to"],
+ oclock => "o'clock",
+ midnight => "midnight",
+ midday => "midday",
+ format => "%v %m %h %d",
+ }
+);
+
+our $Language = "English";
+our $Evening = 18;
+our $Night = 22;
+
+# Preloaded methods go here.
+
+sub humanize_base {
+ my ($hour, $minute) = @_[2,1];
+ my $vague = $minute % 5;
+ my $close_minute = $minute-$vague;
+ my $t = $templates{$Language};
+ my $say_hour;
+ my $daytime ="";
+ if ($vague > 2) {$close_minute += 5}
+ if ($close_minute >30) { $hour++; $hour %=24; }
+ $close_minute /= 5;
+ $close_minute %= 12;
+ if ($hour ==0) {
+ $say_hour = $t->{midnight};
+ } elsif ($hour == 12) {
+ $say_hour = $t->{midday};
+ } else {
+ $say_hour = $t->{numbers}[$hour%12-1];
+ $daytime = $hour <= 12 ? ($t->{daytime}[0]) :
+ $hour >= $Night ? $t->{daytime}[3] :
+ ($hour >= $Evening ? $t->{daytime}[2] :
+ $t->{daytime}[1]); # Afternoon
+ }
+ if ($close_minute==0) {
+ $say_hour .= " ". $t->{oclock} unless $hour ==0 or $hour == 12;
+ }
+ my $say_min = $close_minute ==0? "" : $t->{minutes}[$close_minute-1];
+ my $rv = $t->{format};
+ $rv =~ s/%v/$t->{vagueness}[$vague]/eg;
+ $rv =~ s/%m/$say_min/g;
+ $rv =~ s/%h/$say_hour/g;
+ $rv =~ s/%d/$daytime/g;
+ $rv =~ s/^\s+|(?<=\s)\s|\s+$//g;
+ return $rv;
+}
+
+sub humanize {
+ my @foo = humanize_base(@_);
+ return (shift(@foo)." @foo");
+}
+
+1;
+__END__
+# Below is stub documentation for your module. You better edit it!
+
+=head1 NAME
+
+Time::Human - Convert localtime() format to "speaking clock" time
+
+=head1 SYNOPSIS
+
+ use Time::Human;
+ print "The time is now ", humanize(localtime());
+
+=head1 DESCRIPTION
+
+This module provides a "vague" rendering of the time into natural
+language; it's originally intended for text-to-speech applications
+and other speech-based interfaces.
+
+It's fully internationalised: if you look at the code, you'll see a
+global variable called C<%Time::Human::templates>, which you can fill in
+for other languages. If you do multinationalise it, please send me
+templates for other languages to be added to future releases. You can
+set the default language via the global variable
+C<$Time::Human::Language>
+
+C<$Time::Human::Evening> and C<$Time::Human::Night> decide the hours
+at which afternoon turns to evening and evening turns to night in
+your culture. For instance, Greeks may want evening to start at 11pm;
+for hackers, evening may start at 3am.
+
+=head1 USAGE
+
+=head2 Import Parameters
+
+This module accepts no arguments to it's C<import> method (actually, it doesn't
+ even have an import C<method>).
+
+=head2 Exports
+
+This module exports a single I<symbols>, the C<humanize> function.
+
+=head1 CREDITS
+
+Simon Cozens (SIMON) for originally creating this module.
+
+Ricardo SIGNES (RJBS) for being inhumanly patient in waiting for me to apply a
+one line whitespace trimming patch.
+
+Everyone at the DateTime C<Asylum>.
+
+=head1 SUPPORT
+
+Support for this module is provided via the datetime at perl.org email list. See
+http://lists.perl.org/ for more details
+
+=head1 AUTHOR
+
+Simon Cozens, C<simon at cpan.org>
+
+=head1 CURRENT MAINTAINER
+
+Joshua Hoblitt, C<jhoblitt at cpan.org>
+
+=head1 COPYRIGHT
+
+Copyright (C) 2006-2007 Joshua Hoblitt. All rights reserved.
+Copyright (C) 2001-2002(???) Simon Cozens.
+
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
+The full text of the license can be found in the LICENSE file included with
+this module, or in L<perlartistic> and L<perlgpl> Pods as supplied with Perl
+5.8.1 and later.
+
+=head1 SEE ALSO
+
+L<DateTime>, L<DateTime::Format::Human>
+
+=cut
Added: branches/upstream/libtime-human-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/branches/upstream/libtime-human-perl/current/MANIFEST?rev=6062&op=file
==============================================================================
--- branches/upstream/libtime-human-perl/current/MANIFEST (added)
+++ branches/upstream/libtime-human-perl/current/MANIFEST Mon Jul 30 05:25:06 2007
@@ -1,0 +1,6 @@
+Changes
+Human.pm
+MANIFEST
+Makefile.PL
+test.pl
+META.yml Module meta-data (added by MakeMaker)
Added: branches/upstream/libtime-human-perl/current/META.yml
URL: http://svn.debian.org/wsvn/branches/upstream/libtime-human-perl/current/META.yml?rev=6062&op=file
==============================================================================
--- branches/upstream/libtime-human-perl/current/META.yml (added)
+++ branches/upstream/libtime-human-perl/current/META.yml Mon Jul 30 05:25:06 2007
@@ -1,0 +1,10 @@
+# http://module-build.sourceforge.net/META-spec.html
+#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
+name: Time-Human
+version: 1.03
+version_from: Human.pm
+installdirs: site
+requires:
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.30
Added: branches/upstream/libtime-human-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libtime-human-perl/current/Makefile.PL?rev=6062&op=file
==============================================================================
--- branches/upstream/libtime-human-perl/current/Makefile.PL (added)
+++ branches/upstream/libtime-human-perl/current/Makefile.PL Mon Jul 30 05:25:06 2007
@@ -1,0 +1,8 @@
+use ExtUtils::MakeMaker;
+# See lib/ExtUtils/MakeMaker.pm for details of how to influence
+# the contents of the Makefile that is written.
+WriteMakefile(
+ 'NAME' => 'Time::Human',
+ 'VERSION_FROM' => 'Human.pm', # finds $VERSION
+ 'PREREQ_PM' => {}, # e.g., Module::Name => 1.1
+);
Added: branches/upstream/libtime-human-perl/current/test.pl
URL: http://svn.debian.org/wsvn/branches/upstream/libtime-human-perl/current/test.pl?rev=6062&op=file
==============================================================================
--- branches/upstream/libtime-human-perl/current/test.pl (added)
+++ branches/upstream/libtime-human-perl/current/test.pl Mon Jul 30 05:25:06 2007
@@ -1,0 +1,20 @@
+# Before `make install' is performed this script should be runnable with
+# `make test'. After `make install' it should work as `perl test.pl'
+
+######################### We start with some black magic to print on failure.
+
+# Change 1..1 below to 1..last_test_to_print .
+# (It may become useful if the test is moved to ./t subdirectory.)
+
+BEGIN { $| = 1; print "1..1\n"; }
+END {print "not ok 1\n" unless $loaded;}
+use Time::Human;
+$loaded = 1;
+print "ok 1\n";
+
+######################### End of black magic.
+
+# Insert your test code below (better if it prints "ok 13"
+# (correspondingly "not ok 13") depending on the success of chunk 13
+# of the test code):
+
More information about the Pkg-perl-cvs-commits
mailing list