package DateTrans;

use 5.008005;
use strict;
use warnings;

require Exporter;

our @ISA = qw(Exporter);

# Items to export into callers namespace by default. Note: do not export
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.

# This allows declaration	use DateTrans ':all';
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
# will save memory.

our @EXPORT = qw(monName monNumber timeFormat AmPmFormat dayNumbeFormat);

our $VERSION = '0.01';

sub monName {
my $mon = shift @_;

if($mon eq "Jan") {
my $monName="January";
}elsif($mon eq "Feb"){
my $monName="February";
}elsif($mon eq"Mar"){
my $monName="March";
}elsif($mon eq "Apr"){
my $monName="April";
}elsif($mon eq "May"){
my $monName ="May";
}elsif($mon eq "Jun"){
my $monName="June";
}elsif($mon eq "Jul"){
my $monName="July";
}elsif($mon eq "Aug"){
my $monName="August";
}elsif($mon eq "Sep"){
my $monName="September";
}elsif($mon eq "Oct"){
my $monName="October";
}elsif($mon eq "Nov"){
my $monName="November";
}elsif ($mon eq "Dec"){
my $monName="December";
};

};

sub monNumber {
my $mon = shift @_;

if($mon eq "Jan") {
my $monnum="01";
}elsif($mon eq "Feb"){
my $monnum= "02";
}elsif($mon eq"Mar"){
my $monnum="03";
}elsif($mon eq "Apr"){
my $monnum="04";
}elsif($mon eq "May"){
my $monnum="05";
}elsif($mon eq "Jun"){
my $monnum="06";
}elsif($mon eq "Jul"){
my $monnum="07";
}elsif($mon eq "Aug"){
my $monnum="08";
}elsif($mon eq "Sep"){
my $monnum="09";
}elsif($mon eq "Oct"){
my $monnum="10";
}elsif($mon eq "Nov"){
my $monnum="11";
}elsif ($mon eq "Dec"){
my $monnum="12";
};

};

sub timeFormat{
my $hour = shift @_;

if ($hour < 12){
#print "module \$hour = $hour";
if ($hour != 0){
my $newhour = $hour;
}else{
my $newhour=12;
};

}else{

if ($hour == 12){
my $newhour=12;
}else{
my $newhour = $hour - 12;
};

#my $ampm = "$newhour";
}
#my $newtime = $newhour . $ampm;
};






sub AmPmFormat {
my $houra = shift @_;
#print "\$houra = $houra\n";

if ($houra < 12){
my $ampm ="am";
}else{
my $ampm ="pm";
};

};

sub dayNumbeFormat {
my $day = shift @_;

if ($day < 10){
my $daynuma = substr($day,1,1);
my $daynum = "0$daynuma";
}else{
#my $daynum=$day;
};

};



1;
__END__

 NAME: DateTrans .

SYNOPSIS

To use the DateTrans module, insert the beginning line in your Perl script:
  use DateTrans qw(subroutine name);

or if you are not a superuser:

use lib "/home/mccre004/GPMSscripts/module/DateTrans/lib";
use DateTrans qw(monName monNumber timeFormat AmPmFormat dayNumbeFormat);

where /home/mccre004/GPMSscripts/module is the locatation of the Perl module on your system.

To use the subroutines, first get the date the date/time from unix by doing the following:
my $now=`date`;

Next, seperate the month, day and hour using the substr command:
$mon = substr($now,4,3);
$day=substr($now,8,2);
$hour = substr($now,11,2);

Finally, use these new strings in subroutine calls::  


DESCRIPTION:

 Perl extension for transforming the output of the system date command, which is perl using the Unix date command. This module consists of five subroutines that format the output: monName, monNumber, timeFormat, AmPmFormat and dayNumbeFormat. The      monName subroutine converts the 3 letter month code into the full month name.The monNumber subroutine converts the 3 letter   month code given by the system date command into a two character string based on the month's position in the calendar. The    timeFormat subroutine takes the time output from the UNIX date command and converts from a 24 hour time scale to the more     normal 12 hour time scale. The AmPmFormat subroutine takes the time output from the UNIX date command and converts it to an   "am" or a "pm". The dayNumbeFormat subroutine takes the day output from the Unix date command and  appends a "0" to all days  less than 10.


=head2 EXPORT

None by default.



=head1 SEE ALSO

Mention other useful documentation such as the documentation of
related modules or operating system documentation (such as man pages
in UNIX), or any relevant external documentation such as RFCs or
standards.

If you have a mailing list set up for your module, mention it here.

If you have a web site set up for your module, mention it here.

=head1 AUTHOR

Matt Mccready, E<lt>mccre004@localdomainE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2008 by Matt Mccready

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.5 or,
at your option, any later version of Perl 5 you may have available.


=cut
