Convert-NLS_DATE_FORMAT-0.05/0000755000175000017500000000000011705435542015545 5ustar kolibriekolibrieConvert-NLS_DATE_FORMAT-0.05/META.yml0000644000175000017500000000107111705435542017015 0ustar kolibriekolibrie--- #YAML:1.0 name: Convert-NLS_DATE_FORMAT version: 0.05 abstract: Convert Oracle NLS_DATE_FORMAT <-> strftime Format Strings author: - Nathan Gray license: perl distribution_type: module configure_requires: ExtUtils::MakeMaker: 0 build_requires: ExtUtils::MakeMaker: 0 requires: {} no_index: directory: - t - inc generated_by: ExtUtils::MakeMaker version 6.56 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 Convert-NLS_DATE_FORMAT-0.05/Changes0000644000175000017500000000111411705435474017041 0ustar kolibriekolibrieRevision history for Perl extension Convert::nls_date_format. 0.05 Tue Jan 17 22:23:40 2012 - changed ~~ to =~ for compatibility with older versions of Perl 0.04 Mon Jan 16 15:09:56 2012 - remove quotes from quoted strings within oracle formats (Thank you Yanick Champoux) 0.03 Tue Oct 11 20:48:56 2011 - added ability to specify subsecond granularity (Thank you Jon Bjornstad and Zefram) 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 Convert-NLS_DATE_FORMAT-0.05/MANIFEST0000644000175000017500000000026411705435542016700 0ustar kolibriekolibrieChanges Makefile.PL MANIFEST README t/oracle2posix.t t/posix2oracle.t lib/Convert/NLS_DATE_FORMAT.pm META.yml Module meta-data (added by MakeMaker) Convert-NLS_DATE_FORMAT-0.05/README0000644000175000017500000000207711645163422016431 0ustar kolibriekolibrieConvert-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 None. COPYRIGHT AND LICENCE Copyright (C) 2005, 2006, 2011 by 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. Convert-NLS_DATE_FORMAT-0.05/lib/0000755000175000017500000000000011705435542016313 5ustar kolibriekolibrieConvert-NLS_DATE_FORMAT-0.05/lib/Convert/0000755000175000017500000000000011705435542017733 5ustar kolibriekolibrieConvert-NLS_DATE_FORMAT-0.05/lib/Convert/NLS_DATE_FORMAT.pm0000644000175000017500000001367711705435515022610 0ustar kolibriekolibriepackage 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.05'; 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.'=> '' ], [ XFF9 => '.%9N' ], # special case until X can translate to %{decimal} [ XFF6 => '.%6N' ], # special case until X can translate to %{decimal} [ XFF3 => '.%3N' ], # special case until X can translate to %{decimal} [ 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) = @_; # quoted strings require separate processing return join( '', map { _convert_oracle2posix($_) } split(/(".*?")/, $oracle_format) ); } sub _convert_oracle2posix { my ($oracle_format) = @_; # return quoted strings as-is, with the quotes removed return $1 if $oracle_format =~ m/^"(.*?)"$/; my $string = $oracle_format; foreach my $pair (@formats) { my ($key, $value) = @$pair; # all are case insensitive except am/pm $key = qr/$key/i unless $key =~ m/^[ap]m$/i; # translate formats found in $oracle_format if ($string =~ /(? 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 or C. my $format = oracle2posix('YYYY-MM-DD HH24:MI:SS'); # '%Y-%m-%d %H:%M:%S' Character sequences that should not be translated may be enclosed within double quotes, as specified in the Oracle documentation. my $format = oracle2posix('YYYY-MM-DD"T"HH24:MI:SS'); # '%Y-%m-%dT%H:%M:%S' =item posix2oracle Takes a C or C formatting string and converts it into an Oracle NLS_DATE_FORMAT string. I my $format = posix2oracle('%Y-%m-%d %H:%M:%S'); # 'YYYY-MM-DD HH24:MI:SS' =back =head2 EXPORT None by default. C and C when asked. =head1 SEE ALSO L. =head1 AUTHOR Nathan Gray, Ekolibrie@cpan.orgE =head1 COPYRIGHT AND LICENSE Copyright (C) 2005, 2006, 2011, 2012 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 Convert-NLS_DATE_FORMAT-0.05/t/0000755000175000017500000000000011705435542016010 5ustar kolibriekolibrieConvert-NLS_DATE_FORMAT-0.05/t/oracle2posix.t0000644000175000017500000000354111705101072020576 0ustar kolibriekolibrie# 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' ######################### use Test::More; use Convert::NLS_DATE_FORMAT; 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"T"HH24:MI:SS' => '%Y-%m-%dT%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', 'Day, Month, Year' => '%A, %B, Year', # this one should throw a warning 'Day, Month, Bogus' => '%A, %B, Bogus', # this one should not throw a warning 'YYYY - Q' => '%Y - %{quarter}', 'DD-MON-RR HH.MI.SSXFF9 AM' => '%d-%b-%y %I.%M.%S.%9N %p', 'DD-MON-RR HH.MI.SSXFF6 AM' => '%d-%b-%y %I.%M.%S.%6N %p', 'DD-MON-RR HH.MI.SSXFF AM' => '%d-%b-%y %I.%M.%S.%6N %p', 'DD-MON-RR HH.MI.SSXFF3 AM' => '%d-%b-%y %I.%M.%S.%3N %p', ); plan tests => scalar(keys %tests); ######################### # 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) { is(Convert::NLS_DATE_FORMAT::oracle2posix($nls), $strf, $nls); } Convert-NLS_DATE_FORMAT-0.05/t/posix2oracle.t0000644000175000017500000000245411705067736020622 0ustar kolibriekolibrie# 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' ######################### use Test::More; use Convert::NLS_DATE_FORMAT; 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}', ); plan tests => scalar(keys %tests); ######################### # 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) { is(Convert::NLS_DATE_FORMAT::posix2oracle($strf), $nls, $strf); } Convert-NLS_DATE_FORMAT-0.05/Makefile.PL0000644000175000017500000000114611645163775017532 0ustar kolibriekolibrieuse 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 ', LICENSE => 'perl') : ()), );