r4095 - in /packages/libdatetime-format-db2-perl: ./ branches/ branches/upstream/ branches/upstream/current/ branches/upstream/current/lib/ branches/upstream/current/lib/DateTime/ branches/upstream/current/lib/DateTime/Format/ branches/upstream/current/t/ tags/

gregoa-guest at users.alioth.debian.org gregoa-guest at users.alioth.debian.org
Sun Oct 8 17:19:31 UTC 2006


Author: gregoa-guest
Date: Sun Oct  8 17:19:30 2006
New Revision: 4095

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=4095
Log:
[svn-inject] Installing original source of libdatetime-format-db2-perl

Added:
    packages/libdatetime-format-db2-perl/
    packages/libdatetime-format-db2-perl/branches/
    packages/libdatetime-format-db2-perl/branches/upstream/
    packages/libdatetime-format-db2-perl/branches/upstream/current/
    packages/libdatetime-format-db2-perl/branches/upstream/current/Changes
    packages/libdatetime-format-db2-perl/branches/upstream/current/MANIFEST
    packages/libdatetime-format-db2-perl/branches/upstream/current/META.yml
    packages/libdatetime-format-db2-perl/branches/upstream/current/Makefile.PL
    packages/libdatetime-format-db2-perl/branches/upstream/current/lib/
    packages/libdatetime-format-db2-perl/branches/upstream/current/lib/DateTime/
    packages/libdatetime-format-db2-perl/branches/upstream/current/lib/DateTime/Format/
    packages/libdatetime-format-db2-perl/branches/upstream/current/lib/DateTime/Format/DB2.pm
    packages/libdatetime-format-db2-perl/branches/upstream/current/t/
    packages/libdatetime-format-db2-perl/branches/upstream/current/t/00load.t   (with props)
    packages/libdatetime-format-db2-perl/branches/upstream/current/t/01format.t   (with props)
    packages/libdatetime-format-db2-perl/branches/upstream/current/t/02parse.t   (with props)
    packages/libdatetime-format-db2-perl/tags/

Added: packages/libdatetime-format-db2-perl/branches/upstream/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdatetime-format-db2-perl/branches/upstream/current/Changes?rev=4095&op=file
==============================================================================
--- packages/libdatetime-format-db2-perl/branches/upstream/current/Changes (added)
+++ packages/libdatetime-format-db2-perl/branches/upstream/current/Changes Sun Oct  8 17:19:30 2006
@@ -1,0 +1,6 @@
+
+2005-12-18:
+0.04 - Added parsing of YYYY-MM-DD HH:MM:SS.NNNNNN since thats what DBI
+actually gives us. (odd that)
+
+0.03 - Fixed SYNOPSIS.

Added: packages/libdatetime-format-db2-perl/branches/upstream/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdatetime-format-db2-perl/branches/upstream/current/MANIFEST?rev=4095&op=file
==============================================================================
--- packages/libdatetime-format-db2-perl/branches/upstream/current/MANIFEST (added)
+++ packages/libdatetime-format-db2-perl/branches/upstream/current/MANIFEST Sun Oct  8 17:19:30 2006
@@ -1,0 +1,8 @@
+lib/DateTime/Format/DB2.pm
+Makefile.PL
+MANIFEST			This list of files
+META.yml
+Changes
+t/00load.t
+t/01format.t
+t/02parse.t

Added: packages/libdatetime-format-db2-perl/branches/upstream/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdatetime-format-db2-perl/branches/upstream/current/META.yml?rev=4095&op=file
==============================================================================
--- packages/libdatetime-format-db2-perl/branches/upstream/current/META.yml (added)
+++ packages/libdatetime-format-db2-perl/branches/upstream/current/META.yml Sun Oct  8 17:19:30 2006
@@ -1,0 +1,12 @@
+# http://module-build.sourceforge.net/META-spec.html
+#XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
+name:         DateTime-Format-DB2
+version:      0.04
+version_from: lib/DateTime/Format/DB2.pm
+installdirs:  site
+requires:
+    DateTime:                      0
+    DateTime::Format::Builder:     0
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.17

Added: packages/libdatetime-format-db2-perl/branches/upstream/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdatetime-format-db2-perl/branches/upstream/current/Makefile.PL?rev=4095&op=file
==============================================================================
--- packages/libdatetime-format-db2-perl/branches/upstream/current/Makefile.PL (added)
+++ packages/libdatetime-format-db2-perl/branches/upstream/current/Makefile.PL Sun Oct  8 17:19:30 2006
@@ -1,0 +1,9 @@
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+     NAME          => 'DateTime::Format::DB2',
+     VERSION_FROM  => 'lib/DateTime/Format/DB2.pm',
+     PREREQ_PM     => { 'DateTime'                   => 0,
+                        'DateTime::Format::Builder'  => 0,
+                    },
+);

Added: packages/libdatetime-format-db2-perl/branches/upstream/current/lib/DateTime/Format/DB2.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdatetime-format-db2-perl/branches/upstream/current/lib/DateTime/Format/DB2.pm?rev=4095&op=file
==============================================================================
--- packages/libdatetime-format-db2-perl/branches/upstream/current/lib/DateTime/Format/DB2.pm (added)
+++ packages/libdatetime-format-db2-perl/branches/upstream/current/lib/DateTime/Format/DB2.pm Sun Oct  8 17:19:30 2006
@@ -1,0 +1,150 @@
+package DateTime::Format::DB2;
+
+use strict;
+
+use vars qw ($VERSION);
+
+$VERSION = '0.04';
+
+use DateTime;
+use DateTime::Format::Builder
+    ( parsers =>
+# 12/13/2005
+      { parse_date =>
+        { params => [ qw( year month day ) ],
+          regex  => qr!^(\d\d\d\d)-(\d\d)-(\d\d)$!,
+        },
+# 12:17:46
+        parse_time =>
+        { params => [ qw( hour minute second ) ],
+          regex  => qr!^(\d\d):(\d\d):(\d\d)$!,
+          extra  => { time_zone => 'floating' },
+        },
+# 2005-12-13-12.19.07.276270
+        parse_timestamp =>
+        [ { params => [ qw( year month day hour minute second nanosecond) ],
+            regex  => qr/^(\d\d\d\d)-(\d\d)-(\d\d)-(\d\d)\.(\d\d)\.(\d\d)(\.\d+)?$/,
+            extra  => { time_zone => 'floating' },
+            postprocess => \&_fix_nano
+          },
+        { params => [ qw( year month day hour minute second nanosecond) ],
+            regex  => qr/^(\d\d\d\d)-(\d\d)-(\d\d)\s(\d\d):(\d\d):(\d\d)(\.\d+)?$/,
+            extra  => { time_zone => 'floating' },
+            postprocess => \&_fix_nano
+          },
+        ],
+      },
+    );
+
+sub _fix_nano
+{
+    my %p = @_;
+
+    $p{parsed}{nanosecond} *= 10**9;
+
+    return 1;
+}
+
+sub format_date
+{
+    my ( $self, $dt ) = @_;
+
+    return $dt->ymd('-');
+}
+
+sub format_time
+{
+    my ( $self, $dt ) = @_;
+
+    return $dt->hms(':');
+}
+
+sub format_timestamp
+{
+    my ( $self, $dt ) = @_;
+
+    return $self->format_date($dt) . '-' . $dt->hms('.');
+}
+
+
+1;
+
+__END__
+
+=head1 NAME
+
+DateTime::Format::DB2 - Parse and format DB2 dates and times
+
+=head1 SYNOPSIS
+
+  use DateTime::Format::DB2;
+
+  my $dt = DateTime::Format::DB2->parse_timestamp( '2003-01-16-23.12.01.300000' );
+
+  # 2003-01-16-23.12.01.300000
+  DateTime::Format::DB2->format_timestamp($dt);
+
+=head1 DESCRIPTION
+
+This module understands the formats used by DB2 for its DATE,
+TIME, and TIMESTAMP data types.  It can be used to parse
+these formats in order to create DateTime objects, and it can take a
+DateTime object and produce a string representing it in the DB2
+format.
+
+=head1 METHODS
+
+This class offers the following methods.  All of the parsing methods
+set the returned DateTime object's time zone to the floating time
+zone, because DB2 does not provide time zone information.
+
+=over 4
+
+=item * parse_time($string)
+
+=item * parse_date($string)
+
+=item * parse_timestamp($string)
+
+Given a value of the appropriate type, this method will return a new
+C<DateTime> object.  The time zone for this object will always be the
+floating time zone, because by DB2 stores the local datetime, not
+UTC.
+
+If given an improperly formatted string, this method may die.
+
+=item * format_date($datetime)
+
+=item * format_time($datetime)
+
+=item * format_timestamp($datetime)
+
+Given a C<DateTime> object, this methods returns an appropriately
+formatted string.
+
+=back
+
+=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
+
+Jess Robinson <castaway at desert-island.demon.co.uk>
+
+This module was shamelessly cloned from Dave Rolsky's L<DateTime::Format::MySQL> module.
+
+=head1 COPYRIGHT
+
+Copyright (c) 2005 Jess Robinson.  All rights reserved.  This program
+is free software; you can redistribute it and/or modify it under the
+same terms as Perl itself.
+
+=head1 SEE ALSO
+
+datetime at perl.org mailing list
+
+http://datetime.perl.org/
+
+=cut

Added: packages/libdatetime-format-db2-perl/branches/upstream/current/t/00load.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdatetime-format-db2-perl/branches/upstream/current/t/00load.t?rev=4095&op=file
==============================================================================
--- packages/libdatetime-format-db2-perl/branches/upstream/current/t/00load.t (added)
+++ packages/libdatetime-format-db2-perl/branches/upstream/current/t/00load.t Sun Oct  8 17:19:30 2006
@@ -1,0 +1,5 @@
+use strict;
+
+use Test::More tests => 1;
+
+use_ok( 'DateTime::Format::DB2' );

Propchange: packages/libdatetime-format-db2-perl/branches/upstream/current/t/00load.t
------------------------------------------------------------------------------
    svn:executable = 

Added: packages/libdatetime-format-db2-perl/branches/upstream/current/t/01format.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdatetime-format-db2-perl/branches/upstream/current/t/01format.t?rev=4095&op=file
==============================================================================
--- packages/libdatetime-format-db2-perl/branches/upstream/current/t/01format.t (added)
+++ packages/libdatetime-format-db2-perl/branches/upstream/current/t/01format.t Sun Oct  8 17:19:30 2006
@@ -1,0 +1,22 @@
+use strict;
+
+use Test::More tests => 3;
+
+use DateTime::Format::DB2;
+
+my $mysql = 'DateTime::Format::DB2';
+
+my $dt = DateTime->new( year   => 2000,
+                        month  => 5,
+                        day    => 6,
+                        hour   => 15,
+                        minute => 23,
+                        second => 44,
+                        time_zone => 'UTC',
+                      );
+
+{
+    is( $mysql->format_date($dt), '2000-05-06', 'format_date' );
+    is( $mysql->format_timestamp($dt), '2000-05-06-15.23.44', 'format_datetime' );
+    is( $mysql->format_time($dt), '15:23:44', 'format_time' );
+}

Propchange: packages/libdatetime-format-db2-perl/branches/upstream/current/t/01format.t
------------------------------------------------------------------------------
    svn:executable = 

Added: packages/libdatetime-format-db2-perl/branches/upstream/current/t/02parse.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdatetime-format-db2-perl/branches/upstream/current/t/02parse.t?rev=4095&op=file
==============================================================================
--- packages/libdatetime-format-db2-perl/branches/upstream/current/t/02parse.t (added)
+++ packages/libdatetime-format-db2-perl/branches/upstream/current/t/02parse.t Sun Oct  8 17:19:30 2006
@@ -1,0 +1,43 @@
+use strict;
+
+use Test::More tests => 15;
+
+use DateTime::Format::DB2;
+
+my $db2 = 'DateTime::Format::DB2';
+
+{
+    my $dt = $db2->parse_date( '2003-02-15' );
+    is( $dt->year, 2003 );
+    is( $dt->month, 2 );
+    is( $dt->day, 15 );
+}
+
+# {
+#     my $dt = $db2->parse_time( '10:09:08' );
+#     is( $dt->hour, 10 );
+#     is( $dt->minute, 9 );
+#     is( $dt->second, 8 );
+# }
+
+{
+    my $dt = $db2->parse_timestamp( '2003-02-15-10.09.08.200000' );
+    is( $dt->year, 2003 );
+    is( $dt->month, 2 );
+    is( $dt->day, 15 );
+    is( $dt->hour, 10 );
+    is( $dt->minute, 9 );
+    is( $dt->second, 8 );
+}
+
+{
+    my $dt = $db2->parse_timestamp( '2003-02-15 10:09:08.200000' );
+    is( $dt->year, 2003 );
+    is( $dt->month, 2 );
+    is( $dt->day, 15 );
+    is( $dt->hour, 10 );
+    is( $dt->minute, 9 );
+    is( $dt->second, 8 );
+}
+
+

Propchange: packages/libdatetime-format-db2-perl/branches/upstream/current/t/02parse.t
------------------------------------------------------------------------------
    svn:executable = 




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