r64924 - in /branches/upstream/libdatetime-format-oracle-perl: ./ current/ current/lib/ current/lib/DateTime/ current/lib/DateTime/Format/ current/t/
gregoa at users.alioth.debian.org
gregoa at users.alioth.debian.org
Sun Nov 14 15:11:47 UTC 2010
Author: gregoa
Date: Sun Nov 14 15:11:30 2010
New Revision: 64924
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=64924
Log:
[svn-inject] Installing original source of libdatetime-format-oracle-perl (0.05)
Added:
branches/upstream/libdatetime-format-oracle-perl/
branches/upstream/libdatetime-format-oracle-perl/current/
branches/upstream/libdatetime-format-oracle-perl/current/Changes
branches/upstream/libdatetime-format-oracle-perl/current/MANIFEST
branches/upstream/libdatetime-format-oracle-perl/current/META.yml
branches/upstream/libdatetime-format-oracle-perl/current/Makefile.PL
branches/upstream/libdatetime-format-oracle-perl/current/README
branches/upstream/libdatetime-format-oracle-perl/current/lib/
branches/upstream/libdatetime-format-oracle-perl/current/lib/DateTime/
branches/upstream/libdatetime-format-oracle-perl/current/lib/DateTime/Format/
branches/upstream/libdatetime-format-oracle-perl/current/lib/DateTime/Format/Oracle.pm
branches/upstream/libdatetime-format-oracle-perl/current/t/
branches/upstream/libdatetime-format-oracle-perl/current/t/defaults.t
branches/upstream/libdatetime-format-oracle-perl/current/t/format_datetime.t
branches/upstream/libdatetime-format-oracle-perl/current/t/format_timestamp.t
branches/upstream/libdatetime-format-oracle-perl/current/t/parse_datetime.t
branches/upstream/libdatetime-format-oracle-perl/current/t/parse_timestamp.t
Added: branches/upstream/libdatetime-format-oracle-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-oracle-perl/current/Changes?rev=64924&op=file
==============================================================================
--- branches/upstream/libdatetime-format-oracle-perl/current/Changes (added)
+++ branches/upstream/libdatetime-format-oracle-perl/current/Changes Sun Nov 14 15:11:30 2010
@@ -1,0 +1,22 @@
+Revision history for DateTime-Format-Oracle
+
+0.05 Tue Jun 10 12:55:55 2008
+ - implemented parse_timestamp_with_timezone and
+ format_timestamp_with_timezone
+ - patch provided by Jozef Kutej
+
+0.04 Wed Feb 27 11:09:41 2008
+ - implemented parse_timestamp and format_timestamp
+ - patch provided by Aldo Calpini
+
+0.03 Thu Aug 23 10:41:48 2007
+ - set default value for 'nls_date_format' to use when %ENV
+ variable not set
+ - thanks to jaybuffington at gmail.com for sample patch
+
+0.02 Fri Nov 3 23:40:32 2006
+ - CPAN release
+
+0.01 Sun Jul 23 10:26:58 2006
+ - RFC version posted to datetime at perl.org
+
Added: branches/upstream/libdatetime-format-oracle-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-oracle-perl/current/MANIFEST?rev=64924&op=file
==============================================================================
--- branches/upstream/libdatetime-format-oracle-perl/current/MANIFEST (added)
+++ branches/upstream/libdatetime-format-oracle-perl/current/MANIFEST Sun Nov 14 15:11:30 2010
@@ -1,0 +1,11 @@
+Changes
+MANIFEST
+META.yml # Will be created by "make dist"
+Makefile.PL
+README
+lib/DateTime/Format/Oracle.pm
+t/defaults.t
+t/format_datetime.t
+t/format_timestamp.t
+t/parse_datetime.t
+t/parse_timestamp.t
Added: branches/upstream/libdatetime-format-oracle-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-oracle-perl/current/META.yml?rev=64924&op=file
==============================================================================
--- branches/upstream/libdatetime-format-oracle-perl/current/META.yml (added)
+++ branches/upstream/libdatetime-format-oracle-perl/current/META.yml Sun Nov 14 15:11:30 2010
@@ -1,0 +1,17 @@
+--- #YAML:1.0
+name: DateTime-Format-Oracle
+version: 0.05
+abstract: Parse and format Oracle dates and timestamps
+license: ~
+author:
+ - Nathan Gray <kolibrie at cpan.org>
+generated_by: ExtUtils::MakeMaker version 6.42
+distribution_type: module
+requires:
+ Convert::NLS_DATE_FORMAT: 0
+ DateTime: 0
+ DateTime::Format::Builder: 0
+ Test::More: 0
+meta-spec:
+ url: http://module-build.sourceforge.net/META-spec-v1.3.html
+ version: 1.3
Added: branches/upstream/libdatetime-format-oracle-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-oracle-perl/current/Makefile.PL?rev=64924&op=file
==============================================================================
--- branches/upstream/libdatetime-format-oracle-perl/current/Makefile.PL (added)
+++ branches/upstream/libdatetime-format-oracle-perl/current/Makefile.PL Sun Nov 14 15:11:30 2010
@@ -1,0 +1,17 @@
+use strict;
+use warnings;
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+ NAME => 'DateTime::Format::Oracle',
+ AUTHOR => 'Nathan Gray <kolibrie at cpan.org>',
+ VERSION_FROM => 'lib/DateTime/Format/Oracle.pm',
+ ABSTRACT_FROM => 'lib/DateTime/Format/Oracle.pm',
+ PL_FILES => {},
+ PREREQ_PM => {
+ 'Test::More' => 0,
+ 'DateTime' => 0,
+ 'DateTime::Format::Builder' => 0,
+ 'Convert::NLS_DATE_FORMAT' => 0,
+ },
+);
Added: branches/upstream/libdatetime-format-oracle-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-oracle-perl/current/README?rev=64924&op=file
==============================================================================
--- branches/upstream/libdatetime-format-oracle-perl/current/README (added)
+++ branches/upstream/libdatetime-format-oracle-perl/current/README Sun Nov 14 15:11:30 2010
@@ -1,0 +1,49 @@
+DateTime-Format-Oracle
+
+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, run the following commands:
+
+ perl Makefile.PL
+ make
+ make test
+ make install
+
+
+SUPPORT AND DOCUMENTATION
+
+After installing, you can find documentation for this module with the perldoc command.
+
+ perldoc DateTime::Format::Oracle
+
+You can also look for information at:
+
+ Search CPAN
+ http://search.cpan.org/dist/DateTime-Format-Oracle
+
+ CPAN Request Tracker:
+ http://rt.cpan.org/NoAuth/Bugs.html?Dist=DateTime-Format-Oracle
+
+ AnnoCPAN, annotated CPAN documentation:
+ http://annocpan.org/dist/DateTime-Format-Oracle
+
+ CPAN Ratings:
+ http://cpanratings.perl.org/d/DateTime-Format-Oracle
+
+COPYRIGHT AND LICENCE
+
+Copyright (C) 2006, 2008 Nathan Gray
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
Added: branches/upstream/libdatetime-format-oracle-perl/current/lib/DateTime/Format/Oracle.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-oracle-perl/current/lib/DateTime/Format/Oracle.pm?rev=64924&op=file
==============================================================================
--- branches/upstream/libdatetime-format-oracle-perl/current/lib/DateTime/Format/Oracle.pm (added)
+++ branches/upstream/libdatetime-format-oracle-perl/current/lib/DateTime/Format/Oracle.pm Sun Nov 14 15:11:30 2010
@@ -1,0 +1,453 @@
+package DateTime::Format::Oracle;
+
+use strict;
+
+use Carp;
+use DateTime;
+use DateTime::Format::Builder;
+use Convert::NLS_DATE_FORMAT;
+
+our $VERSION = '0.05';
+our $nls_date_format = 'YYYY-MM-DD HH24:MI:SS';
+our $nls_timestamp_format = 'YYYY-MM-DD HH24:MI:SS';
+our $nls_timestamp_tz_format = 'YYYY-MM-DD HH24:MI:SS TZHTZM';
+
+=head1 NAME
+
+DateTime::Format::Oracle - Parse and format Oracle dates and timestamps
+
+=head1 SYNOPSIS
+
+ use DateTime::Format::Oracle;
+
+ $ENV{'NLS_DATE_FORMAT'} = 'YYYY-MM-DD HH24:MI:SS';
+ my $dt = DateTime::Format::Oracle->parse_datetime('2003-01-16 23:12:01');
+ my $string = DateTime::Format::Oracle->format_datetime($dt);
+
+=head1 DESCRIPTION
+
+This module may be used to convert Oracle date and timestamp values
+into C<DateTime> objects. It also can take a C<DateTime> object and
+produce a date string matching the C<NLS_DATE_FORMAT>.
+
+Oracle has flexible date formatting via its C<NLS_DATE_FORMAT> session
+variable. Date values will be returned from Oracle according to the
+current value of that variable. Date values going into Oracle must also
+match the current setting of C<NLS_DATE_FORMAT>.
+
+Timestamp values will match either the C<NLS_TIMESTAMP_FORMAT> or
+C<NLS_TIMESTAMP_TZ_FORMAT> session variables.
+
+This module keeps track of these Oracle session variable values by
+examining environment variables of the same name. Each time one of
+Oracle's formatting session variables is updated, the C<%ENV> hash
+must also be updated.
+
+=head1 METHODS
+
+This class offers the following methods.
+
+=over 4
+
+=item * nls_date_format
+
+This method is used to determine the current value of Oracle's
+C<NLS_DATE_FORMAT>. It currently just reads the value from
+
+ $ENV{'NLS_DATE_FORMAT'}
+
+or if that is not set, from the package variable C<$nls_date_format>,
+which has a default value of C<YYYY-MM-DD HH24:MI:SS>. This is
+a good default to have, but is not Oracle's default. Dates will fail
+to parse if Oracle's NLS_DATE_FORMAT and the value from this method
+are not the same.
+
+If you want to use the default from this module, you can do something
+like this after you connect to Oracle:
+
+ $dbh->do(
+ "alter session set nls_date_format = '" .
+ DateTime::Format::Oracle->nls_date_format .
+ "'"
+ );
+
+=cut
+
+sub nls_date_format { $ENV{NLS_DATE_FORMAT} || $nls_date_format }
+
+=item * nls_timestamp_format
+
+This method is used to determine the current value of Oracle's
+C<NLS_TIMESTAMP_FORMAT>. It currently just reads the value from
+
+ $ENV{'NLS_TIMESTAMP_FORMAT'}
+
+or if that is not set, from the package variable C<$nls_timestamp_format>,
+which has a default value of C<YYYY-MM-DD HH24:MI:SS>. This is
+a good default to have, but is not Oracle's default. Dates will fail
+to parse if Oracle's NLS_TIMESTAMP_FORMAT and the value from this method
+are not the same.
+
+If you want to use the default from this module, you can do something
+like this after you connect to Oracle:
+
+ $dbh->do(
+ "alter session set nls_timestamp_format = '" .
+ DateTime::Format::Oracle->nls_timestamp_format .
+ "'"
+ );
+
+=cut
+
+sub nls_timestamp_format { $ENV{NLS_TIMESTAMP_FORMAT} || $nls_timestamp_format }
+
+=item * nls_timestamp_tz_format
+
+This method is used to determine the current value of Oracle's
+C<NLS_TIMESTAMP_TZ_FORMAT>. It currently just reads the value from
+
+ $ENV{'NLS_TIMESTAMP_TZ_FORMAT'}
+
+or if that is not set, from the package variable C<$nls_timestamp_tz_format>,
+which has a default value of C<YYYY-MM-DD HH24:MI:SS TZHTZM>. This is
+a good default to have, but is not Oracle's default. Dates will fail
+to parse if Oracle's NLS_TIMESTAMP_TZ_FORMAT and the value from this method
+are not the same.
+
+If you want to use the default from this module, you can do something
+like this after you connect to Oracle:
+
+ $dbh->do(
+ "alter session set nls_timestamp_tz_format = '" .
+ DateTime::Format::Oracle->nls_timestamp_tz_format .
+ "'"
+ );
+
+=cut
+
+sub nls_timestamp_tz_format { $ENV{NLS_TIMESTAMP_TZ_FORMAT} || $nls_timestamp_tz_format }
+
+=item * parse_datetime
+
+Given a string containing a date and/or time representation
+matching C<NLS_DATE_FORMAT>, this method will return a new
+C<DateTime> object.
+
+If given an improperly formatted string, this method may die.
+
+=cut
+
+sub parse_datetime { $_[0]->current_date_parser->(@_); }
+
+=item * parse_date
+
+Alias to C<parse_datetime>. Oracle's date datatype also holds
+time information.
+
+=cut
+
+*parse_date = \&parse_datetime;
+
+=item * parse_timestamp
+
+Given a string containing a date and/or time representation
+matching C<NLS_TIMESTAMP_FORMAT>, this method will return a new
+C<DateTime> object.
+
+If given an improperly formatted string, this method may die.
+
+=cut
+
+sub parse_timestamp { $_[0]->current_timestamp_parser->(@_); }
+
+=item * parse_timestamptz
+=item * parse_timestamp_with_time_zone
+
+Given a string containing a date and/or time representation
+matching C<NLS_TIMESTAMP_TZ_FORMAT>, this method will return a new
+C<DateTime> object.
+
+If given an improperly formatted string, this method may die.
+
+=cut
+
+sub parse_timestamptz { $_[0]->current_timestamptz_parser->(@_); }
+*parse_timestamp_with_time_zone = \&parse_timestamptz;
+
+=item * current_date_parser
+
+The current C<DateTime::Format::Builder> generated parsing method
+used by C<parse_datetime> and C<parse_date>.
+
+=cut
+
+*current_date_parser = _parser_generator('current_date_format');
+
+=item * current_timestamp_parser
+
+The current C<DateTime::Format::Builder> generated parsing method
+used by C<parse_timestamp>.
+
+=cut
+
+*current_timestamp_parser = _parser_generator('current_timestamp_format');
+
+=item * current_timestamptz_parser
+
+The current C<DateTime::Format::Builder> generated parsing method
+used by C<parse_timestamptz>.
+
+=cut
+
+*current_timestamptz_parser = _parser_generator('current_timestamptz_format');
+
+sub _parser_generator {
+ # takes a method name for getting the current POSIX format
+ # returns a parser generator code ref
+ my $previous_format = '';
+ my $previous_parser = '';
+ my $method = shift;
+ sub {
+ my ( $self ) = @_;
+ unless ($previous_format eq (my $current_format = $self->$method())) {
+ $previous_format = $current_format;
+ $previous_parser = $self->_create_parser_method($current_format);
+ }
+ return $previous_parser;
+ }
+}
+
+sub _create_parser_method {
+ # takes a strptime format, returns a parser method code ref
+ my ( $self, $date_format ) = @_;
+ my %parse_date = ( strptime => { pattern => $date_format } );
+ my $parser = DateTime::Format::Builder->create_parser(\%parse_date);
+ return DateTime::Format::Builder->create_method($parser);
+}
+
+=item * format_datetime
+
+Given a C<DateTime> object, this method returns a string matching
+the current value of C<NLS_DATE_FORMAT>.
+
+It is important to keep the value of C<$ENV{'NLS_DATE_FORMAT'}> the
+same as the value of the Oracle session variable C<NLS_DATE_FORMAT>.
+
+To determine the current value of Oracle's C<NLS_DATE_FORMAT>:
+
+ select NLS_DATE_FORMAT from NLS_SESSION_PARAMETERS
+
+To reset Oracle's C<NLS_DATE_FORMAT>:
+
+ alter session set NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'
+
+It is generally a good idea to set C<NLS_DATE_FORMAT> to an
+unambiguos value, with four-digit year, and hour, minute, and second.
+
+=cut
+
+sub format_datetime {
+ my ($self, $dt) = @_;
+ return $dt->strftime($self->current_date_format);
+}
+
+=item * format_date
+
+Alias to C<format_datetime>.
+
+=cut
+
+*format_date = \&format_datetime;
+
+=item * format_timestamp
+
+Given a C<DateTime> object, this method returns a string matching
+the current value of C<NLS_TIMESTAMP_FORMAT>.
+
+It is important to keep the value of C<$ENV{'NLS_TIMESTAMP_FORMAT'}> the
+same as the value of the Oracle session variable C<NLS_TIMESTAMP_FORMAT>.
+
+To determine the current value of Oracle's C<NLS_TIMESTAMP_FORMAT>:
+
+ select NLS_TIMESTAMP_FORMAT from NLS_SESSION_PARAMETERS
+
+To reset Oracle's C<NLS_TIMESTAMP_FORMAT>:
+
+ alter session set NLS_TIMESTAMP_FORMAT='YYYY-MM-DD HH24:MI:SS'
+
+It is generally a good idea to set C<NLS_TIMESTAMP_FORMAT> to an
+unambiguos value, with four-digit year, and hour, minute, and second.
+
+=cut
+
+sub format_timestamp {
+ my ($self, $dt) = @_;
+ return $dt->strftime($self->current_timestamp_format);
+}
+
+=item * format_timestamptz
+=item * format_timestamp_with_time_zone
+
+Given a C<DateTime> object, this method returns a string matching
+the current value of C<NLS_TIMESTAMP_TZ_FORMAT>.
+
+It is important to keep the value of C<$ENV{'NLS_TIMESTAMP_TZ_FORMAT'}> the
+same as the value of the Oracle session variable C<NLS_TIMESTAMP_TZ_FORMAT>.
+
+To determine the current value of Oracle's C<NLS_TIMESTAMP_TZ_FORMAT>:
+
+ select NLS_TIMESTAMP_TZ_FORMAT from NLS_SESSION_PARAMETERS
+
+To reset Oracle's C<NLS_TIMESTAMP_TZ_FORMAT>:
+
+ alter session set NLS_TIMESTAMP_TZ_FORMAT='YYYY-MM-DD HH24:MI:SS TZHTZM'
+
+It is generally a good idea to set C<NLS_TIMESTAMP_TZ_FORMAT> to an
+unambiguos value, with four-digit year, and hour, minute, and second.
+
+=cut
+
+sub format_timestamptz {
+ my ($self, $dt) = @_;
+ return $dt->strftime($self->current_timestamptz_format);
+}
+
+*format_timestamp_with_time_zone = \&format_timestamptz;
+
+=item * current_date_format
+
+The current generated method used by C<format_datetime>,
+C<format_date>, and C<current_date_parser> to keep track of
+the C<strptime> translation of C<NLS_DATE_FORMAT>.
+
+=cut
+
+*current_date_format = _format_generator('nls_date_format');
+
+=item * current_timestamp_format
+
+The current generated method used by C<format_timestamp>,
+C<format_timestamp_with_time_zone>, and C<current_timestamp_parser> to keep track of
+the C<strptime> translation of C<NLS_TIMESTAMP_FORMAT>.
+
+=cut
+
+*current_timestamp_format = _format_generator('nls_timestamp_format');
+
+=item * current_timestamptz_format
+
+The current generated method used by C<format_timestamptz>,
+C<format_timestamp_with_time_zone>, and C<current_timestamp_parser> to keep track of
+the C<strptime> translation of C<NLS_TIMESTAMP_FORMAT>.
+
+=cut
+
+*current_timestamptz_format = _format_generator('nls_timestamp_tz_format');
+
+sub _format_generator {
+ # takes a method name for getting the current Oracle format
+ # returns a format generator code ref
+ my $previous_nls_format = '';
+ my $previous_format = '';
+ my $method = shift;
+ sub {
+ my ( $self ) = @_;
+ unless ($previous_nls_format eq (my $current_nls_format = $self->$method())) {
+ $previous_nls_format = $current_nls_format;
+ $previous_format = $self->oracle_to_posix($current_nls_format);
+ }
+ return $previous_format;
+ }
+}
+
+=item * oracle_to_posix
+
+Given an C<NLS_DATE_FORMAT>, C<NLS_TIMESTAMP_FORMAT>, or
+C<NLS_TIMESTAMP_TZ_FORMAT> value, this method returns a
+C<DateTime>-compatible C<strptime> format value.
+
+Translation is currently handled by C<Convert::NLS_DATE_FORMAT>.
+
+=cut
+
+sub oracle_to_posix {
+ my ( $self, $nls_format ) = @_;
+ Convert::NLS_DATE_FORMAT::oracle2posix($nls_format);
+}
+
+=back
+
+=cut
+
+1;
+
+__END__
+
+=head1 LIMITATIONS
+
+Oracle is more flexible with the case of names, such as the month,
+whereas C<DateTime> generally returns names in C<ucfirst> format.
+
+ MONTH -> FEBRUARY
+ Month -> February
+ month -> february
+
+All translate to:
+
+ %B -> February
+
+=head2 TIME ZONES
+
+Oracle returns all dates and timestamps in a time zone similar to
+the C<DateTime> floating time zone, except for 'timestamp with time zone'
+columns.
+
+=head2 INTERVAL ELEMENTS
+
+I have not implemented C<parse_duration>, C<format_duration>,
+C<parse_interval>, nor C<format_interval>, and have no plans to do so.
+
+If you need these features, unit tests, method implementations, and
+pointers to documentation are all welcome.
+
+=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 TODO
+
+Possibly read an environment variable to determine a time zone to
+use instead of 'floating'.
+
+Test and document creating an instance via C<new>.
+
+=head1 AUTHOR
+
+Nathan Gray, E<lt>kolibrie at cpan.orgE<gt>
+
+=head1 ACKNOWLEDGEMENTS
+
+I might have put this module off for another couple years
+without the lure of Jifty, Catalyst, and DBIx::Class pulling
+at me.
+
+Thanks to Dan Horne for his RFC draft of this module.
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright (C) 2006, 2008 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.
+
+=head1 SEE ALSO
+
+Convert::NLS_DATE_FORMAT
+
+datetime at perl.org mailing list
+
+http://datetime.perl.org/
+
+=cut
Added: branches/upstream/libdatetime-format-oracle-perl/current/t/defaults.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-oracle-perl/current/t/defaults.t?rev=64924&op=file
==============================================================================
--- branches/upstream/libdatetime-format-oracle-perl/current/t/defaults.t (added)
+++ branches/upstream/libdatetime-format-oracle-perl/current/t/defaults.t Sun Nov 14 15:11:30 2010
@@ -1,0 +1,14 @@
+use strict;
+use Test::More tests => 1;
+
+use DateTime::Format::Oracle;
+
+my %tests = (
+ nls_date_format => 'YYYY-MM-DD HH24:MI:SS',
+);
+
+foreach my $method (keys %tests) {
+ local $ENV{uc($method)} = '';
+ is(DateTime::Format::Oracle->$method(), $tests{$method}, "default value for $method");
+}
+
Added: branches/upstream/libdatetime-format-oracle-perl/current/t/format_datetime.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-oracle-perl/current/t/format_datetime.t?rev=64924&op=file
==============================================================================
--- branches/upstream/libdatetime-format-oracle-perl/current/t/format_datetime.t (added)
+++ branches/upstream/libdatetime-format-oracle-perl/current/t/format_datetime.t Sun Nov 14 15:11:30 2010
@@ -1,0 +1,32 @@
+use strict;
+# Shamelessly stolen from DateTime::Format::MySQL - Thanks Dave
+use Test::More tests => 6;
+use DateTime::Format::Oracle;
+
+my $class = 'DateTime::Format::Oracle';
+
+my $dt = DateTime->new(
+ year => 2000,
+ month => 5,
+ day => 6,
+ hour => 15,
+ minute => 23,
+ second => 44,
+ time_zone => 'UTC',
+);
+
+my %tests = (
+ '2000-05-06 15:23:44' => 'YYYY-MM-DD HH24:MI:SS',
+ '2000-05-06 15:23:44 UTC' => 'YYYY-MM-DD HH24:MI:SS TZR',
+ '06-May-00' => 'DD-Mon-RR',
+ '06-May-00 03.23.44.000000 PM' => 'DD-Mon-RR HH.MI.SSXFF AM',
+ '06-May-00 03.23.44.000000 PM UTC' => 'DD-Mon-RR HH.MI.SSXFF AM TZR',
+ 'Saturday, 06 May 2000' => 'DAY, DD Mon YYYY',
+);
+
+foreach my $result (keys %tests) {
+ my $nls_format = $tests{$result};
+ local $ENV{NLS_DATE_FORMAT} = $nls_format;
+ is($class->format_date($dt), $result, "format_date $nls_format");
+}
+
Added: branches/upstream/libdatetime-format-oracle-perl/current/t/format_timestamp.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-oracle-perl/current/t/format_timestamp.t?rev=64924&op=file
==============================================================================
--- branches/upstream/libdatetime-format-oracle-perl/current/t/format_timestamp.t (added)
+++ branches/upstream/libdatetime-format-oracle-perl/current/t/format_timestamp.t Sun Nov 14 15:11:30 2010
@@ -1,0 +1,32 @@
+use strict;
+# Shamelessly stolen from DateTime::Format::MySQL - Thanks Dave
+use Test::More tests => 6;
+use DateTime::Format::Oracle;
+
+my $class = 'DateTime::Format::Oracle';
+
+my $dt = DateTime->new(
+ year => 2000,
+ month => 5,
+ day => 6,
+ hour => 15,
+ minute => 23,
+ second => 44,
+ time_zone => 'UTC',
+);
+
+my %tests = (
+ '2000-05-06 15:23:44' => 'YYYY-MM-DD HH24:MI:SS',
+ '2000-05-06 15:23:44 UTC' => 'YYYY-MM-DD HH24:MI:SS TZR',
+ '06-May-00' => 'DD-Mon-RR',
+ '06-May-00 03.23.44.000000 PM' => 'DD-Mon-RR HH.MI.SSXFF AM',
+ '06-May-00 03.23.44.000000 PM UTC' => 'DD-Mon-RR HH.MI.SSXFF AM TZR',
+ 'Saturday, 06 May 2000' => 'DAY, DD Mon YYYY',
+);
+
+foreach my $result (keys %tests) {
+ my $nls_format = $tests{$result};
+ local $ENV{NLS_TIMESTAMP_FORMAT} = $nls_format;
+ is($class->format_timestamp($dt), $result, "format_timestamp $nls_format");
+}
+
Added: branches/upstream/libdatetime-format-oracle-perl/current/t/parse_datetime.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-oracle-perl/current/t/parse_datetime.t?rev=64924&op=file
==============================================================================
--- branches/upstream/libdatetime-format-oracle-perl/current/t/parse_datetime.t (added)
+++ branches/upstream/libdatetime-format-oracle-perl/current/t/parse_datetime.t Sun Nov 14 15:11:30 2010
@@ -1,0 +1,90 @@
+use strict;
+use Test::More tests => 4 * 7; # strings * methods
+
+use DateTime::Format::Oracle;
+
+my $class = 'DateTime::Format::Oracle';
+
+my %tests = (
+ '2003-02-15' => {
+ format => 'YYYY-MM-DD',
+ year => 2003,
+ month => 2,
+ day => 15,
+ hour => 0,
+ minute => 0,
+ second => 0,
+ time_zone => 'floating',
+ },
+ '15-FEB-03' => {
+ format => 'DD-MON-RR',
+ year => 2003,
+ month => 2,
+ day => 15,
+ hour => 0,
+ minute => 0,
+ second => 0,
+ time_zone => 'floating',
+ },
+ '2003-02-15 14:39:06' => {
+ format => 'YYYY-MM-DD HH24:MI:SS',
+ year => 2003,
+ month => 2,
+ day => 15,
+ hour => 14,
+ minute => 39,
+ second => 6,
+ time_zone => 'floating',
+ },
+ '15-FEB-03 02.39.06.167901 PM' => {
+ format => 'DD-MON-RR HH.MI.SSXFF AM',
+ year => 2003,
+ month => 2,
+ day => 15,
+ hour => 14,
+ minute => 39,
+ second => 6,
+ time_zone => 'floating',
+ },
+ # time zone parsing seems to not work in DateTime::Format::Builder
+ #'2003-02-15 14:39:06 AMERICA/NEW_YORK' => {
+ # format => 'YYYY-MM-DD HH24:MI:SS TZR',
+ # year => 2003,
+ # month => 2,
+ # day => 15,
+ # hour => 14,
+ # minute => 39,
+ # second => 6,
+ # time_zone => 'America/New_York',
+ #},
+ #'15-FEB-03 02.39.06.167901 PM AMERICA/NEW_YORK' => {
+ # format => 'DD-MON-RR HH.MI.SSXFF AM TZR',
+ # year => 2003,
+ # month => 2,
+ # day => 15,
+ # hour => 14,
+ # minute => 39,
+ # second => 6,
+ # time_zone => 'America/New_York',
+ #},
+);
+
+foreach my $string (keys %tests) {
+ my $params = $tests{$string};
+ my $nls_format = delete $params->{format};
+ local $ENV{NLS_DATE_FORMAT} = $nls_format;
+ my $dt;
+ eval { $dt = $class->parse_date($string) };
+ if ($@) {
+ warn "failed to parse date '$string' via format '$nls_format' (" . $class->current_date_format . ")";
+ next;
+ }
+ foreach my $method (keys %$params) {
+ if ($method eq 'time_zone') {
+ is($dt->$method->name, $params->{$method}, "$nls_format $method");
+ } else {
+ is($dt->$method, $params->{$method}, "$nls_format $method");
+ }
+ }
+}
+
Added: branches/upstream/libdatetime-format-oracle-perl/current/t/parse_timestamp.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-oracle-perl/current/t/parse_timestamp.t?rev=64924&op=file
==============================================================================
--- branches/upstream/libdatetime-format-oracle-perl/current/t/parse_timestamp.t (added)
+++ branches/upstream/libdatetime-format-oracle-perl/current/t/parse_timestamp.t Sun Nov 14 15:11:30 2010
@@ -1,0 +1,90 @@
+use strict;
+use Test::More tests => 4 * 7; # strings * methods
+
+use DateTime::Format::Oracle;
+
+my $class = 'DateTime::Format::Oracle';
+
+my %tests = (
+ '2003-02-15' => {
+ format => 'YYYY-MM-DD',
+ year => 2003,
+ month => 2,
+ day => 15,
+ hour => 0,
+ minute => 0,
+ second => 0,
+ time_zone => 'floating',
+ },
+ '15-FEB-03' => {
+ format => 'DD-MON-RR',
+ year => 2003,
+ month => 2,
+ day => 15,
+ hour => 0,
+ minute => 0,
+ second => 0,
+ time_zone => 'floating',
+ },
+ '2003-02-15 14:39:06' => {
+ format => 'YYYY-MM-DD HH24:MI:SS',
+ year => 2003,
+ month => 2,
+ day => 15,
+ hour => 14,
+ minute => 39,
+ second => 6,
+ time_zone => 'floating',
+ },
+ '15-FEB-03 02.39.06.167901 PM' => {
+ format => 'DD-MON-RR HH.MI.SSXFF AM',
+ year => 2003,
+ month => 2,
+ day => 15,
+ hour => 14,
+ minute => 39,
+ second => 6,
+ time_zone => 'floating',
+ },
+ # time zone parsing seems to not work in DateTime::Format::Builder
+ #'2003-02-15 14:39:06 AMERICA/NEW_YORK' => {
+ # format => 'YYYY-MM-DD HH24:MI:SS TZR',
+ # year => 2003,
+ # month => 2,
+ # day => 15,
+ # hour => 14,
+ # minute => 39,
+ # second => 6,
+ # time_zone => 'America/New_York',
+ #},
+ #'15-FEB-03 02.39.06.167901 PM AMERICA/NEW_YORK' => {
+ # format => 'DD-MON-RR HH.MI.SSXFF AM TZR',
+ # year => 2003,
+ # month => 2,
+ # day => 15,
+ # hour => 14,
+ # minute => 39,
+ # second => 6,
+ # time_zone => 'America/New_York',
+ #},
+);
+
+foreach my $string (keys %tests) {
+ my $params = $tests{$string};
+ my $nls_format = delete $params->{format};
+ local $ENV{NLS_TIMESTAMP_FORMAT} = $nls_format;
+ my $dt;
+ eval { $dt = $class->parse_timestamp($string) };
+ if ($@) {
+ warn "failed to parse date '$string' via format '$nls_format' (" . $class->current_timestamp_format . ")";
+ next;
+ }
+ foreach my $method (keys %$params) {
+ if ($method eq 'time_zone') {
+ is($dt->$method->name, $params->{$method}, "$nls_format $method");
+ } else {
+ is($dt->$method, $params->{$method}, "$nls_format $method");
+ }
+ }
+}
+
More information about the Pkg-perl-cvs-commits
mailing list