r36360 - in /trunk/libdatetime-format-flexible-perl: Changes META.yml README TODO debian/changelog lib/DateTime/Format/Flexible.pm t/data/tests.txt t/parsing.t

ryan52-guest at users.alioth.debian.org ryan52-guest at users.alioth.debian.org
Mon May 25 04:31:02 UTC 2009


Author: ryan52-guest
Date: Mon May 25 04:30:57 2009
New Revision: 36360

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=36360
Log:
New upstream release

Modified:
    trunk/libdatetime-format-flexible-perl/Changes
    trunk/libdatetime-format-flexible-perl/META.yml
    trunk/libdatetime-format-flexible-perl/README
    trunk/libdatetime-format-flexible-perl/TODO
    trunk/libdatetime-format-flexible-perl/debian/changelog
    trunk/libdatetime-format-flexible-perl/lib/DateTime/Format/Flexible.pm
    trunk/libdatetime-format-flexible-perl/t/data/tests.txt
    trunk/libdatetime-format-flexible-perl/t/parsing.t

Modified: trunk/libdatetime-format-flexible-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-flexible-perl/Changes?rev=36360&op=diff
==============================================================================
--- trunk/libdatetime-format-flexible-perl/Changes (original)
+++ trunk/libdatetime-format-flexible-perl/Changes Mon May 25 04:30:57 2009
@@ -1,4 +1,8 @@
 Revision history for Perl module DateTime::Format::Flexible
+
+0.09 Sun May 24 22:00:00 2009
+   - add a real copyright for Debian packaging
+   - fix parsing a bare 4 digit year. (thanks Dominic Rose, rt #46278)
 
 0.08 Wed Apr 22 14:00:00 2009
     - fix some pod errors, give an example for european hinting

Modified: trunk/libdatetime-format-flexible-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-flexible-perl/META.yml?rev=36360&op=diff
==============================================================================
--- trunk/libdatetime-format-flexible-perl/META.yml (original)
+++ trunk/libdatetime-format-flexible-perl/META.yml Mon May 25 04:30:57 2009
@@ -1,18 +1,24 @@
 --- #YAML:1.0
-name:                DateTime-Format-Flexible
-version:             0.08
-abstract:            DateTime::Format::Flexible - Flexibly parse strings and turn them into DateTime objects.
-license:             perl
-author:              
+name:               DateTime-Format-Flexible
+version:            0.09
+abstract:           DateTime::Format::Flexible - Flexibly parse strings and turn them into DateTime objects.
+author:
     - Tom Heady (cpan at punch.net)
-generated_by:        ExtUtils::MakeMaker version 6.42
-distribution_type:   module
-requires:     
-    DateTime:                      0
-    DateTime::Format::Builder:     0.74
-    DateTime::TimeZone:            0
-    Readonly:                      0.06
-    Test::Simple:                  0.44
+license:            perl
+distribution_type:  module
+configure_requires:
+    ExtUtils::MakeMaker:  0
+requires:
+    DateTime:             0
+    DateTime::Format::Builder:  0.74
+    DateTime::TimeZone:   0
+    Readonly:             0.06
+    Test::Simple:         0.44
+no_index:
+    directory:
+        - t
+        - inc
+generated_by:       ExtUtils::MakeMaker version 6.48
 meta-spec:
-    url:     http://module-build.sourceforge.net/META-spec-v1.3.html
-    version: 1.3
+    url:      http://module-build.sourceforge.net/META-spec-v1.4.html
+    version:  1.4

Modified: trunk/libdatetime-format-flexible-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-flexible-perl/README?rev=36360&op=diff
==============================================================================
--- trunk/libdatetime-format-flexible-perl/README (original)
+++ trunk/libdatetime-format-flexible-perl/README Mon May 25 04:30:57 2009
@@ -4,7 +4,7 @@
 
 SYNOPSIS
       use DateTime::Format::Flexible;
-      my $dt = DateTime::Format::Flexible->build( 'January 8, 1999' );
+      my $dt = DateTime::Format::Flexible->parse_datetime( 'January 8, 1999' );
       # $dt = a DateTime object set at 1999-01-08T00:00:00
 
 DESCRIPTION
@@ -12,25 +12,117 @@
     certain way and thought "Why can't the computer just figure out what
     date I wanted?", this module is for you.
 
-    It attempts to take any string you give it and parse it into a DateTime
-    object.
+    DateTime::Format::Flexible attempts to take any string you give it and
+    parse it into a DateTime object.
 
-    For supported string formats, see the test file. If you can think of any
-    that I do not cover, please let me know.
+    The test file tests 2500+ variations of date/time strings. If you can
+    think of any that I do not cover, please let me know.
 
 USAGE
-    This module uses DateTime::Format::Builder under the covers. It only has
-    one method (build).
+    This module uses DateTime::Format::Builder under the covers.
 
-  build
-    my $dt = DateTime::Format::Flexible->build( $date );
+  build, parse_datetime
+    build and parse_datetime do the same thing. Give it a string and it
+    attempts to parse it and return a DateTime object.
 
-    A small list of supported formats: YYYYMMDDTHHMMSS YYYYMMDDTHHMM
-    YYYYMMDDTHH YYYYMMDD YYYYMM MM-DD-YYYY MM-D-YYYY MM-DD-YY M-DD-YY
-    YYYY/DD/MM YYYY/M/DD YYYY/MM/D M-D MM-D M-D-Y Month D, YYYY Mon D, YYYY
-    Mon D, YYYY HH:MM:SS ...
+    If it can't it will throw an exception.
 
-    there are 2800+ variations that are detected correctly in the test file.
+     my $dt = DateTime::Format::Flexible->build( $date );
+
+     my $dt = DateTime::Format::Flexible->parse_datetime( $date );
+
+     my $dt = DateTime::Format::Flexible->parse_datetime(
+         $date,
+         strip    => [qr{\.\z}],
+         tz_map   => {EDT => 'America/New_York'},
+         european => 1
+     );
+
+    *   "strip"
+
+        Remove a substring from the string you are trying to parse. You can
+        pass multiple regexes in an arrayref.
+
+        example:
+
+         my $dt = DateTime::Format::Flexible->parse_datetime(
+             '2011-04-26 00:00:00 (registry time)' ,
+             strip => [qr{\(registry time\)\z}] ,
+         );
+         # $dt is now 2011-04-26T00:00:00
+
+        This is helpful if you have a load of dates you want to normalize
+        and you know of some weird formatting beforehand.
+
+    *   "tz_map"
+
+        map a given timezone to another recognized timezone Values are given
+        as a hashref.
+
+        example:
+
+         my $dt = DateTime::Format::Flexible->parse_datetime(
+             '25-Jun-2009 EDT' ,
+             tz_map => {EDT => 'America/New_York'}
+         );
+         # $dt is now 2009-06-25T00:00:00 with a timezone of America/New_York
+
+        This is helpful if you have a load of dates that have timezones that
+        are not recognized by DateTime::Timezone.
+
+    *   "european"
+
+        If european is set to a true value, an attempt will be made to parse
+        as a DD-MM-YYYY date instead of the default MM-DD-YYYY. There is a
+        chance that this will not do the right thing due to ambiguity.
+
+        example:
+
+         my $dt = DateTime::Format::Flexible->parse_datetime(
+             '16/06/2010' , european => 1 ,
+         );
+         # $dt is now 2010-06-16T00:00:00
+
+  Example formats
+    A small list of supported formats:
+
+    YYYYMMDDTHHMMSS
+    YYYYMMDDTHHMM
+    YYYYMMDDTHH
+    YYYYMMDD
+    YYYYMM
+    MM-DD-YYYY
+    MM-D-YYYY
+    MM-DD-YY
+    M-DD-YY
+    YYYY/DD/MM
+    YYYY/M/DD
+    YYYY/MM/D
+    M-D
+    MM-D
+    M-D-Y
+    Month D, YYYY
+    Mon D, YYYY
+    Mon D, YYYY HH:MM:SS
+    ...
+
+    there are 9000+ variations that are detected correctly in the test files
+    (see t/data/* for most of them).
+
+NOTES
+    The DateTime website http://datetime.perl.org/?Modules as of march 2008
+    lists this module under 'Confusing' and recommends the use of
+    DateTime::Format::Natural.
+
+    Unfortunately I do not agree. DateTime::Format::Natural currently fails
+    more than 2000 of my parsing tests. DateTime::Format::Flexible supports
+    different types of date/time strings than DateTime::Format::Natural. I
+    think there is utility in that can be found in both of them.
+
+    The whole goal of DateTime::Format::Flexible is to accept just about any
+    crazy date/time string that a user might care to enter.
+    DateTime::Format::Natural seems to be a little stricter in what it can
+    parse.
 
 BUGS
     You cannot use a 1 or 2 digit year as the first field:
@@ -40,8 +132,6 @@
 
     It would get confused with MM-DD-YY
 
-    It also prefers the US format of MM-DD over the European DD-MM.
-
 AUTHOR
         Tom Heady
         CPAN ID: thinc
@@ -49,7 +139,9 @@
         cpan at punch.net
         http://www.punch.net/
 
-COPYRIGHT
+COPYRIGHT and LICENSE
+    Copyright 2007-2009 Tom Heady
+
     This program is free software; you can redistribute it and/or modify it
     under the same terms as Perl itself.
 
@@ -57,5 +149,5 @@
     with this module.
 
 SEE ALSO
-    perl(1). DateTime::Format::Builder
+    DateTime::Format::Builder, DateTime::Timezone, DateTime::Format::Natural
 

Modified: trunk/libdatetime-format-flexible-perl/TODO
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-flexible-perl/TODO?rev=36360&op=diff
==============================================================================
--- trunk/libdatetime-format-flexible-perl/TODO (original)
+++ trunk/libdatetime-format-flexible-perl/TODO Mon May 25 04:30:57 2009
@@ -1,5 +1,5 @@
 TODO list for Perl module DateTime::Format::Flexible
 
-- Support timezones
+- add more tests
 
 

Modified: trunk/libdatetime-format-flexible-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-flexible-perl/debian/changelog?rev=36360&op=diff
==============================================================================
--- trunk/libdatetime-format-flexible-perl/debian/changelog (original)
+++ trunk/libdatetime-format-flexible-perl/debian/changelog Mon May 25 04:30:57 2009
@@ -1,5 +1,6 @@
-libdatetime-format-flexible-perl (0.08-1) UNRELEASED; urgency=low
+libdatetime-format-flexible-perl (0.09-1) UNRELEASED; urgency=low
 
+  [ Jonathan Yu ]
   TODO:
   - I don't find a copyright statement anywhere in the code
     - sent email, -- Ryan52
@@ -7,4 +8,7 @@
 
   * Initial Release. (Closes: #529543)
 
- -- Jonathan Yu <frequency at cpan.org>  Tue, 19 May 2009 21:38:53 -0400
+  [ Ryan Niebur ]
+  * New upstream release
+
+ -- Ryan Niebur <ryanryan52 at gmail.com>  Sun, 24 May 2009 21:30:47 -0700

Modified: trunk/libdatetime-format-flexible-perl/lib/DateTime/Format/Flexible.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-flexible-perl/lib/DateTime/Format/Flexible.pm?rev=36360&op=diff
==============================================================================
--- trunk/libdatetime-format-flexible-perl/lib/DateTime/Format/Flexible.pm (original)
+++ trunk/libdatetime-format-flexible-perl/lib/DateTime/Format/Flexible.pm Mon May 25 04:30:57 2009
@@ -2,7 +2,7 @@
 use strict;
 use warnings;
 
-our $VERSION = '0.08';
+our $VERSION = '0.09';
 
 use base 'DateTime::Format::Builder';
 
@@ -48,6 +48,7 @@
 Readonly my $MDYHMSAP => [ qw( month day year hour minute second ampm ) ];
 Readonly my $MDHMSY => [ qw( month day hour minute second year ) ];
 
+Readonly my $Y => [ qw( year ) ];
 Readonly my $YM => [ qw( year month ) ];
 Readonly my $YMD => [ qw( year month day ) ];
 Readonly my $YMDH => [ qw( year month day hour ) ];
@@ -179,6 +180,7 @@
  { length => 11,       params => $YMDH,     regex => qr{\A(\d{4})(\d{2})(\d{2})T(\d{2})\z} },
  { length => 8,        params => $YMD,      regex => qr{\A(\d{4})(\d{2})(\d{2})\z} } ,
  { length => 6,        params => $YM,       regex => qr{\A(\d{4})(\d{2})\z} },
+ { length => 4,        params => $Y,        regex => qr{\A(\d{4})\z} },
 
  ########################################################
  ##### bare times
@@ -661,7 +663,9 @@
     cpan at punch.net
     http://www.punch.net/
 
-=head1 COPYRIGHT
+=head1 COPYRIGHT and LICENSE
+
+Copyright 2007-2009 Tom Heady
 
 This program is free software; you can redistribute
 it and/or modify it under the same terms as Perl itself.

Modified: trunk/libdatetime-format-flexible-perl/t/data/tests.txt
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-flexible-perl/t/data/tests.txt?rev=36360&op=diff
==============================================================================
--- trunk/libdatetime-format-flexible-perl/t/data/tests.txt (original)
+++ trunk/libdatetime-format-flexible-perl/t/data/tests.txt Mon May 25 04:30:57 2009
@@ -2510,3 +2510,4 @@
 2006//-Dec///08 12:33:46 pm => 2006-12-08T12:33:46
 1221753628 => 2008-09-18T16:00:28
 1221753628.79859 => 2008-09-18T16:00:28
+2007 => 2007-01-01T00:00:00

Modified: trunk/libdatetime-format-flexible-perl/t/parsing.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-flexible-perl/t/parsing.t?rev=36360&op=diff
==============================================================================
--- trunk/libdatetime-format-flexible-perl/t/parsing.t (original)
+++ trunk/libdatetime-format-flexible-perl/t/parsing.t Mon May 25 04:30:57 2009
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 8078;
+use Test::More tests => 8079;
 use File::Spec::Functions 'catfile';
 
 use t::lib::helper;




More information about the Pkg-perl-cvs-commits mailing list