r64915 - in /branches/upstream/libconvert-nls-date-format-perl: ./ current/ current/lib/ current/lib/Convert/ current/t/

gregoa at users.alioth.debian.org gregoa at users.alioth.debian.org
Sun Nov 14 14:58:27 UTC 2010


Author: gregoa
Date: Sun Nov 14 14:57:58 2010
New Revision: 64915

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=64915
Log:
[svn-inject] Installing original source of libconvert-nls-date-format-perl (0.02)

Added:
    branches/upstream/libconvert-nls-date-format-perl/
    branches/upstream/libconvert-nls-date-format-perl/current/
    branches/upstream/libconvert-nls-date-format-perl/current/Changes
    branches/upstream/libconvert-nls-date-format-perl/current/MANIFEST
    branches/upstream/libconvert-nls-date-format-perl/current/META.yml
    branches/upstream/libconvert-nls-date-format-perl/current/Makefile.PL
    branches/upstream/libconvert-nls-date-format-perl/current/README
    branches/upstream/libconvert-nls-date-format-perl/current/lib/
    branches/upstream/libconvert-nls-date-format-perl/current/lib/Convert/
    branches/upstream/libconvert-nls-date-format-perl/current/lib/Convert/NLS_DATE_FORMAT.pm
    branches/upstream/libconvert-nls-date-format-perl/current/t/
    branches/upstream/libconvert-nls-date-format-perl/current/t/oracle2posix.t
    branches/upstream/libconvert-nls-date-format-perl/current/t/posix2oracle.t

Added: branches/upstream/libconvert-nls-date-format-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libconvert-nls-date-format-perl/current/Changes?rev=64915&op=file
==============================================================================
--- branches/upstream/libconvert-nls-date-format-perl/current/Changes (added)
+++ branches/upstream/libconvert-nls-date-format-perl/current/Changes Sun Nov 14 14:57:58 2010
@@ -1,0 +1,9 @@
+Revision history for Perl extension Convert::nls_date_format.
+
+0.02  Fri Nov  3 14:54:52 2006
+	- cleaned up for CPAN
+
+0.01  Wed Apr 20 10:16:36 2005
+	- original version; created by h2xs 1.23 with options
+		-AXn Convert::nls_date_format -b 5.6.0
+

Added: branches/upstream/libconvert-nls-date-format-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libconvert-nls-date-format-perl/current/MANIFEST?rev=64915&op=file
==============================================================================
--- branches/upstream/libconvert-nls-date-format-perl/current/MANIFEST (added)
+++ branches/upstream/libconvert-nls-date-format-perl/current/MANIFEST Sun Nov 14 14:57:58 2010
@@ -1,0 +1,8 @@
+Changes
+Makefile.PL
+MANIFEST
+README
+t/oracle2posix.t
+t/posix2oracle.t
+lib/Convert/NLS_DATE_FORMAT.pm
+META.yml                                 Module meta-data (added by MakeMaker)

Added: branches/upstream/libconvert-nls-date-format-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libconvert-nls-date-format-perl/current/META.yml?rev=64915&op=file
==============================================================================
--- branches/upstream/libconvert-nls-date-format-perl/current/META.yml (added)
+++ branches/upstream/libconvert-nls-date-format-perl/current/META.yml Sun Nov 14 14:57:58 2010
@@ -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:         Convert-NLS_DATE_FORMAT
+version:      0.02
+version_from: lib/Convert/NLS_DATE_FORMAT.pm
+installdirs:  site
+requires:
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.30

Added: branches/upstream/libconvert-nls-date-format-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libconvert-nls-date-format-perl/current/Makefile.PL?rev=64915&op=file
==============================================================================
--- branches/upstream/libconvert-nls-date-format-perl/current/Makefile.PL (added)
+++ branches/upstream/libconvert-nls-date-format-perl/current/Makefile.PL Sun Nov 14 14:57:58 2010
@@ -1,0 +1,12 @@
+use 5.006;
+use ExtUtils::MakeMaker;
+# See lib/ExtUtils/MakeMaker.pm for details of how to influence
+# the contents of the Makefile that is written.
+WriteMakefile(
+    NAME              => 'Convert::NLS_DATE_FORMAT',
+    VERSION_FROM      => 'lib/Convert/NLS_DATE_FORMAT.pm', # finds $VERSION
+    PREREQ_PM         => {}, # e.g., Module::Name => 1.1
+    ($] >= 5.005 ?     ## Add these new keywords supported since 5.005
+      (ABSTRACT_FROM  => 'lib/Convert/NLS_DATE_FORMAT.pm', # retrieve abstract from module
+       AUTHOR         => 'Nathan Gray <kolibrie at cpan.org>') : ()),
+);

Added: branches/upstream/libconvert-nls-date-format-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libconvert-nls-date-format-perl/current/README?rev=64915&op=file
==============================================================================
--- branches/upstream/libconvert-nls-date-format-perl/current/README (added)
+++ branches/upstream/libconvert-nls-date-format-perl/current/README Sun Nov 14 14:57:58 2010
@@ -1,0 +1,40 @@
+Convert-nls_date_format version 0.01
+====================================
+
+The README is used to introduce the module and provide instructions on
+how to install the module, any machine dependencies it may have (for
+example C compilers and installed libraries) and any other information
+that should be provided before the module is installed.
+
+A README file is required for CPAN modules since CPAN extracts the
+README file from a module distribution so that people browsing the
+archive can use it get an idea of the modules uses. It is usually a
+good idea to provide version information here so that people can
+decide whether fixes for the module are worth downloading.
+
+INSTALLATION
+
+To install this module type the following:
+
+   perl Makefile.PL
+   make
+   make test
+   make install
+
+DEPENDENCIES
+
+This module requires these other modules and libraries:
+
+  blah blah blah
+
+COPYRIGHT AND LICENCE
+
+Put the correct copyright and licence information here.
+
+Copyright (C) 2005 by kolibrie
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself, either Perl version 5.8.4 or,
+at your option, any later version of Perl 5 you may have available.
+
+

Added: branches/upstream/libconvert-nls-date-format-perl/current/lib/Convert/NLS_DATE_FORMAT.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libconvert-nls-date-format-perl/current/lib/Convert/NLS_DATE_FORMAT.pm?rev=64915&op=file
==============================================================================
--- branches/upstream/libconvert-nls-date-format-perl/current/lib/Convert/NLS_DATE_FORMAT.pm (added)
+++ branches/upstream/libconvert-nls-date-format-perl/current/lib/Convert/NLS_DATE_FORMAT.pm Sun Nov 14 14:57:58 2010
@@ -1,0 +1,182 @@
+package Convert::NLS_DATE_FORMAT;
+
+use 5.006;
+use strict;
+use warnings;
+
+require Exporter;
+
+our @ISA = qw(Exporter);
+our %EXPORT_TAGS = ( 'all' => [ qw(oracle2posix posix2oracle) ] );
+our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
+our @EXPORT = qw();
+
+our $VERSION = '0.02';
+
+our @formats = (
+    Q     => '%{quarter}', # quarter number
+    WW    => '%U', # week number
+    IW    => '%V', # ISO week number
+    W     => '', # week in month
+    J     => '', # Julian days since 31 Dec 4713BC
+    YEAR  => '', # year spelled out
+    SYYYY => '%Y', # signed year (BC is negative)
+    YYYY  => '%Y', # four digit year
+    IYYY  => '%G', # ISO four digit year
+    YYY   => '', # last three digits of year
+    IYY   => '', # ISO last three digits of year
+    YY    => '%y', # last two digits of year
+    IY    => '%g', # ISO last two digits of year
+    RR    => '%y', # last two digits of year relative to current date
+    Month => '%B', # month spelled out
+    Mon   => '%b', # three-letter abbreviation month
+    MM    => '%m', # month number
+    RM    => '', # roman numeral month XXII
+    DDD   => '%j', # day of year
+    DD    => '%d', # day of month
+    Day   => '%A', # day of week spelled out
+    Dy    => '%a', # three-letter abbreviation day of week
+    D     => '%u', # day of week
+    HH24  => '%H', # hours (24)
+    HH12  => '%I', # hours (12)
+    HH    => '%I', # hours (12)
+    MI    => '%M', # minutes
+    SSSSS => '', # seconds since midnight
+    SS    => '%S', # seconds
+    AM    => '%p', # displays AM or PM
+    PM    => '%p',
+    'A.M.'=> '', # displays A.M. or P.M.
+    'P.M.'=> '',
+    am    => '%P', # displays am or pm
+    pm    => '%P',
+    'a.m.'=> '', # displays a.m. or p.m.
+    'p.m.'=> '',
+    BC    => '', # displays BC or AD
+    AD    => '',
+    'B.C.'=> '', # displays B.C. or A.D.
+    'A.D.'=> '',
+    XFF   => '.%6N', # special case until X can translate to %{decimal}
+    FF    => '%6N',
+    TZHTZM=> '%z', # time zone hour offset from UTC
+    TZH   => '%z',
+    TZR   => '%Z', # time zone name
+    TH    => '', # appends 'st', 'nd', 'rd', 'th'
+    Y     => '', # last digit of year
+    I     => '', # ISO last digit of year
+);
+
+my %formats = generate_formats();
+
+sub oracle2posix {
+    my $oracle_format = shift;
+    my $posix_format = $oracle_format;
+    my $c = 0;
+    while (my $key = $formats[$c++]) {
+        my $value = $formats[$c++];
+	if ($value) {
+	    if ($key =~ m/^[ap]m$/i) {
+		$posix_format =~ s/(?<!%)$key/$value/g;
+	    } else {
+		$posix_format =~ s/(?<!%)$key/$value/gi;
+	    }
+	}
+    }
+    return $posix_format;
+}
+
+sub posix2oracle {
+    my $format = shift;
+    # regex from DateTime
+    $format =~ s/
+		    (%{\w+})
+	        /
+		    $formats{$1} ? $formats{$1} : "\%$1"
+	        /sgex;
+    # special case for XFF until X can translate to %{decimal}
+    $format =~ s/
+                    (\.%\d?N)
+                /
+                    "XFF"
+                /sgex;
+    # regex from Date::Format
+    $format =~ s/
+		    (%[%a-zA-Z])
+	        /
+		    $formats{$1} ? $formats{$1} : "\%$1"
+	        /sgex;
+    return $format;
+}
+
+sub generate_formats {
+    my $c = 0;
+    my %f = ();
+    while (my $nls = $formats[$c++]) {
+        my $posix_format = $formats[$c++];
+	if ($posix_format) {
+	    $f{$posix_format} = $nls;
+	}
+    }
+    $f{'%z'} = 'TZHTZM'; # special case
+    return %f;
+}
+
+1;
+__END__
+
+=head1 NAME
+
+Convert::NLS_DATE_FORMAT - Convert Oracle NLS_DATE_FORMAT <-> strftime Format Strings
+
+=head1 SYNOPSIS
+
+  use Convert::NLS_DATE_FORMAT qw(oracle2posix posix2oracle);
+  my $strptime = oracle2posix($NLS_DATE_FORMAT);
+  $NLS_DATE_FORMAT = posix2oracle($strftime);
+
+=head1 DESCRIPTION
+
+Convert Oracle's NLS_DATE_FORMAT string into a strptime format string, or
+the reverse.
+
+=head2 Functions
+
+=over 4
+
+=item oracle2posix
+
+Takes an Oracle NLS_DATE_FORMAT string and converts it into formatting
+string compatible with C<strftime> or C<strptime>.
+
+  my $format = oracle2posix('YYYY-MM-DD HH24:MI:SS'); # '%Y-%m-%d %H:%M:%S'
+
+=item posix2oracle
+
+Takes a C<strftime> or C<strptime> formatting string and converts it
+into an Oracle NLS_DATE_FORMAT string. I<It is possible to create strings
+which Oracle will not accept as valid NLS_DATE_FORMAT strings.>
+
+  my $format = posix2oracle('%Y-%m-%d %H:%M:%S'); # 'YYYY-MM-DD HH24:MI:SS'
+
+=back
+
+=head2 EXPORT
+
+None by default. C<oracle2posix> and C<posix2oracle> when asked.
+
+=head1 SEE ALSO
+
+L<DateTime::Format::Oracle>.
+
+=head1 AUTHOR
+
+Nathan Gray, E<lt>kolibrie at cpan.orgE<gt>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2005, 2006 Nathan Gray
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself, either Perl version 5.8.4 or,
+at your option, any later version of Perl 5 you may have available.
+
+=cut

Added: branches/upstream/libconvert-nls-date-format-perl/current/t/oracle2posix.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libconvert-nls-date-format-perl/current/t/oracle2posix.t?rev=64915&op=file
==============================================================================
--- branches/upstream/libconvert-nls-date-format-perl/current/t/oracle2posix.t (added)
+++ branches/upstream/libconvert-nls-date-format-perl/current/t/oracle2posix.t Sun Nov 14 14:57:58 2010
@@ -1,0 +1,36 @@
+# Before `make install' is performed this script should be runnable with
+# `make test'. After `make install' it should work as `perl Convert-NLS_DATE_FORMAT.t'
+
+#########################
+
+# change 'tests => 1' to 'tests => last_test_to_print';
+
+use Test;
+BEGIN {
+our %tests = (
+    'YYYY-MM-DD HH24:MI:SS TZR'    => '%Y-%m-%d %H:%M:%S %Z',
+    'YYYY-MM-DD HH24:MI:SS TZHTZM' => '%Y-%m-%d %H:%M:%S %z',
+    'YYYY-MM-DD HH24:MI:SS'        => '%Y-%m-%d %H:%M:%S',
+    'YYYY-MM-DD HH:MI:SS pm'       => '%Y-%m-%d %I:%M:%S %P',
+    'yyyy-mm-dd hh:mi:ss pm'       => '%Y-%m-%d %I:%M:%S %P',
+    'YYYY-MM-DD HH:MI:SS PM'       => '%Y-%m-%d %I:%M:%S %p',
+    'DD Mon YYYY'                  => '%d %b %Y',
+    'DD-MON-RR'                    => '%d-%b-%y', # default NLS_DATE_FORMAT
+    'DD-MON-RR HH.MI.SSXFF AM'     => '%d-%b-%y %I.%M.%S.%6N %p', # default NLS_TIMESTAMP_FORMAT
+    'DD-MON-RR HH.MI.SSXFF AM TZR' => '%d-%b-%y %I.%M.%S.%6N %p %Z', # default NLS_TIMESTAMP_TZ_FORMAT
+    'Day, DD Month, YYYY'          => '%A, %d %B, %Y',
+    'YYYY - Q'                     => '%Y - %{quarter}',
+);
+};
+BEGIN { plan tests => scalar(keys %tests) + 1 };
+use Convert::NLS_DATE_FORMAT;
+ok(1); # If we made it this far, we're ok.
+
+#########################
+
+# Insert your test code below, the Test::More module is use()ed here so read
+# its man page ( perldoc Test::More ) for help writing this test script.
+
+while (my ($nls, $strf) = each %tests) {
+    ok(Convert::NLS_DATE_FORMAT::oracle2posix($nls), $strf, $nls);
+}

Added: branches/upstream/libconvert-nls-date-format-perl/current/t/posix2oracle.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libconvert-nls-date-format-perl/current/t/posix2oracle.t?rev=64915&op=file
==============================================================================
--- branches/upstream/libconvert-nls-date-format-perl/current/t/posix2oracle.t (added)
+++ branches/upstream/libconvert-nls-date-format-perl/current/t/posix2oracle.t Sun Nov 14 14:57:58 2010
@@ -1,0 +1,35 @@
+# Before `make install' is performed this script should be runnable with
+# `make test'. After `make install' it should work as `perl Convert-NLS_DATE_FORMAT.t'
+
+#########################
+
+# change 'tests => 1' to 'tests => last_test_to_print';
+
+use Test;
+BEGIN {
+our %tests = (
+    'YYYY-MM-DD HH24:MI:SS TZR'    => '%Y-%m-%d %H:%M:%S %Z',
+    'YYYY-MM-DD HH24:MI:SS TZHTZM' => '%Y-%m-%d %H:%M:%S %z',
+    'YYYY-MM-DD HH24:MI:SS'        => '%Y-%m-%d %H:%M:%S',
+    'YYYY-MM-DD HH:MI:SS pm'       => '%Y-%m-%d %I:%M:%S %P',
+    'YYYY-MM-DD HH:MI:SS PM'       => '%Y-%m-%d %I:%M:%S %p',
+    'DD Mon YYYY'                  => '%d %b %Y',
+    'DD-Mon-RR'                    => '%d-%b-%y', # default NLS_DATE_FORMAT
+    'DD-Mon-RR HH.MI.SSXFF PM'     => '%d-%b-%y %I.%M.%S.%6N %p', # default NLS_TIMESTAMP_FORMAT
+    'DD-Mon-RR HH.MI.SSXFF PM TZR' => '%d-%b-%y %I.%M.%S.%6N %p %Z', # default NLS_TIMESTAMP_TZ_FORMAT
+    'Day, DD Month, YYYY'          => '%A, %d %B, %Y',
+    'YYYY - Q'                     => '%Y - %{quarter}',
+);
+};
+BEGIN { plan tests => scalar(keys %tests) + 1 };
+use Convert::NLS_DATE_FORMAT;
+ok(1); # If we made it this far, we're ok.
+
+#########################
+
+# Insert your test code below, the Test::More module is use()ed here so read
+# its man page ( perldoc Test::More ) for help writing this test script.
+
+while (my ($nls, $strf) = each %tests) {
+    ok(Convert::NLS_DATE_FORMAT::posix2oracle($strf), $nls, $strf);
+}




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