[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] koha/C4 Date.pm [rel_2_2]
From: |
Mason James |
Subject: |
[Koha-cvs] koha/C4 Date.pm [rel_2_2] |
Date: |
Tue, 16 Jan 2007 02:39:54 +0000 |
CVSROOT: /sources/koha
Module name: koha
Branch: rel_2_2
Changes by: Mason James <sushi> 07/01/16 02:39:54
Modified files:
C4 : Date.pm
Log message:
perltidy before commit
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Date.pm?cvsroot=koha&only_with_tag=rel_2_2&r1=1.13.4.2&r2=1.13.4.3
Patches:
Index: Date.pm
===================================================================
RCS file: /sources/koha/koha/C4/Date.pm,v
retrieving revision 1.13.4.2
retrieving revision 1.13.4.3
diff -u -b -r1.13.4.2 -r1.13.4.3
--- Date.pm 15 Jan 2007 17:47:00 -0000 1.13.4.2
+++ Date.pm 16 Jan 2007 02:39:54 -0000 1.13.4.3
@@ -4,7 +4,8 @@
use strict;
use C4::Context;
-use Date::Calc qw(Parse_Date Decode_Date_EU Decode_Date_US Time_to_Date
check_date);
+use Date::Calc
+ qw(Parse_Date Decode_Date_EU Decode_Date_US Time_to_Date check_date);
require Exporter;
@@ -20,126 +21,120 @@
&format_date_in_iso
);
+sub get_date_format {
-sub get_date_format
-{
#Get the database handle
my $dbh = C4::Context->dbh;
return C4::Context->preference('dateformat');
}
-sub display_date_format
-{
+sub display_date_format {
my $dateformat = get_date_format();
- if ( $dateformat eq "us" )
- {
+ if ( $dateformat eq "us" ) {
return "mm/dd/yyyy";
}
- elsif ( $dateformat eq "metric" )
- {
+ elsif ( $dateformat eq "metric" ) {
return "dd/mm/yyyy";
}
- elsif ( $dateformat eq "iso" )
- {
+ elsif ( $dateformat eq "iso" ) {
return "yyyy-mm-dd";
}
- else
- {
- return "Invalid date format: $dateformat. Please change in
system preferences";
+ else {
+ return
+"Invalid date format: $dateformat. Please change in system preferences";
}
}
-
-sub format_date
-{
+sub format_date {
my $olddate = shift;
my $newdate;
- if ( ! $olddate )
- {
+ if ( !$olddate ) {
return "";
}
-# warn $olddate;
-# $olddate=~s#/|\.|-##g;
- my ($year,$month,$day)=Parse_Date($olddate);
- ($year,$month,$day)=split /-|\/|\.|:/,$olddate unless ($year && $month);
-# warn "$olddate annee $year mois $month jour $day";
- if ($year>0 && $month>0){
+ # warn $olddate;
+ # $olddate=~s#/|\.|-##g;
+ my ( $year, $month, $day ) = Parse_Date($olddate);
+ ( $year, $month, $day ) = split /-|\/|\.|:/, $olddate
+ unless ( $year && $month );
+
+ # warn "$olddate annee $year mois $month jour $day";
+ if ( $year > 0 && $month > 0 ) {
my $dateformat = get_date_format();
- $dateformat="metric" if (index(":",$olddate)>0);
- if ( $dateformat eq "us" )
- {
- $newdate = sprintf("%02d/%02d/%04d",$month,$day,$year);
- }
- elsif ( $dateformat eq "metric" )
- {
- $newdate = sprintf("%02d/%02d/%04d",$day,$month,$year);
+ $dateformat = "metric" if ( index( ":", $olddate ) > 0 );
+ if ( $dateformat eq "us" ) {
+ $newdate = sprintf( "%02d/%02d/%04d", $month, $day, $year );
}
- elsif ( $dateformat eq "iso" )
- {
+ elsif ( $dateformat eq "metric" ) {
+ $newdate = sprintf( "%02d/%02d/%04d", $day, $month, $year );
+ }
+ elsif ( $dateformat eq "iso" ) {
+
# Date_Init("DateFormat=iso");
- $newdate = sprintf("%04d-%02d-%02d",$year,$month,$day);
+ $newdate = sprintf( "%04d-%02d-%02d", $year, $month, $day );
}
- else
- {
- return "Invalid date format: $dateformat. Please change in system
preferences";
+ else {
+ return
+"Invalid date format: $dateformat. Please change in system preferences";
}
-# warn "newdate :$newdate";
+
+ # warn "newdate :$newdate";
}
return $newdate;
}
-sub format_date_in_iso
-{
+sub format_date_in_iso {
my $olddate = shift;
my $newdate;
- if ( ! $olddate )
- {
+ if ( !$olddate ) {
return "";
}
my $dateformat = get_date_format();
- my ($year,$month,$day);
+ my ( $year, $month, $day );
my @date;
- my $tmpolddate=$olddate;
- $tmpolddate=~s#/|\.|-|\\##g;
- $dateformat="metric" if (index(":",$olddate)>0);
- if ( $dateformat eq "us" )
- {
- ($month,$day,$year)=split /-|\/|\.|:/,$olddate unless ($year &&
$month);
- if ($month>0 && $day >0){
+ my $tmpolddate = $olddate;
+ $tmpolddate =~ s#/|\.|-|\\##g;
+ $dateformat = "metric" if ( index( ":", $olddate ) > 0 );
+ if ( $dateformat eq "us" ) {
+ ( $month, $day, $year ) = split /-|\/|\.|:/, $olddate
+ unless ( $year && $month );
+ if ( $month > 0 && $day > 0 ) {
@date = Decode_Date_US($tmpolddate);
- } else {
- @date=($year, $month,$day)
+ }
+ else {
+ @date = ( $year, $month, $day );
}
}
- elsif ( $dateformat eq "metric" )
- {
- ($day,$month,$year)=split /-|\/|\.|:/,$olddate unless ($year &&
$month);
- if ($month>0 && $day >0){
+ elsif ( $dateformat eq "metric" ) {
+ ( $day, $month, $year ) = split /-|\/|\.|:/, $olddate
+ unless ( $year && $month );
+ if ( $month > 0 && $day > 0 ) {
@date = Decode_Date_EU($tmpolddate);
- } else {
- @date=($year, $month,$day)
}
+ else {
+ @date = ( $year, $month, $day );
+ }
+ }
+ elsif ( $dateformat eq "iso" ) {
+ ( $year, $month, $day ) = split /-|\/|\.|:/, $olddate
+ unless ( $year && $month );
+ if ( $month > 0 && $day > 0 ) {
+ @date = ( $year, $month, $day )
+ if ( check_date( $year, $month, $day ) );
}
- elsif ( $dateformat eq "iso" )
- {
- ($year,$month,$day)=split /-|\/|\.|:/,$olddate unless ($year &&
$month);
- if ($month>0 && $day >0){
- @date=($year, $month,$day) if (check_date($year,$month,$day));
- } else {
- @date=($year, $month,$day)
+ else {
+ @date = ( $year, $month, $day );
}
}
- else
- {
+ else {
return "9999-99-99";
}
- $newdate = sprintf("%04d-%02d-%02d",$date[0],$date[1],$date[2]);
+ $newdate = sprintf( "%04d-%02d-%02d", $date[0], $date[1], $date[2] );
return $newdate;
}