[Rt-commit] r4031 - in rt/branches/3.7-EXPERIMENTAL: . lib/RT

ruz at bestpractical.com ruz at bestpractical.com
Fri Nov 4 20:56:49 EST 2005


Author: ruz
Date: Fri Nov  4 20:56:48 2005
New Revision: 4031

Modified:
   rt/branches/3.7-EXPERIMENTAL/   (props changed)
   rt/branches/3.7-EXPERIMENTAL/lib/RT/Date.pm
Log:
 r1174 at cubic-pc:  cubic | 2005-11-05 04:58:20 +0300
  r1169 at cubic-pc:  cubic | 2005-11-05 02:09:23 +0300
  * no more then refactoring
 


Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/Date.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/Date.pm	(original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/Date.pm	Fri Nov  4 20:56:48 2005
@@ -166,8 +166,8 @@
     my %args = ( Format => 'unix',
                  Value  => time,
                  @_ );
-    if ( !$args{'Value'}
-         || ( ( $args{'Value'} =~ /^\d*$/ ) and ( $args{'Value'} == 0 ) ) ) {
+
+    unless( $args{'Value'} ) {
         $self->Unix(-1);
         return ( $self->Unix() );
     }
@@ -175,7 +175,6 @@
     if ( $args{'Format'} =~ /^unix$/i ) {
         $self->Unix( $args{'Value'} );
     }
-
     elsif ( $args{'Format'} =~ /^(sql|datemanip|iso)$/i ) {
         $args{'Value'} =~ s!/!-!g;
 
@@ -199,28 +198,24 @@
 
             #now that we've parsed it, deal with the case where everything
             #was 0
-            if ( $mon == -1 ) {
-                $self->Unix(-1);
-            }
-            else {
+            return ($self->Unix(-1)) if $mon < 0 || $mon > 11;
 
-                #Dateamnip strings aren't in GMT.
-                if ( $args{'Format'} =~ /^datemanip$/i ) {
-                    $self->Unix(
-                          timelocal( $sec, $min, $hours, $mday, $mon, $year ) );
-                }
-
-                #ISO and SQL dates are in GMT
-                else {
-                    $self->Unix(
-                             timegm( $sec, $min, $hours, $mday, $mon, $year ) );
-                }
+            #Dateamnip strings aren't in GMT.
+            if ( $args{'Format'} =~ /^datemanip$/i ) {
+                $self->Unix(
+                      timelocal( $sec, $min, $hours, $mday, $mon, $year ) );
+            }
 
-                $self->Unix(-1) unless $self->Unix;
+            #ISO and SQL dates are in GMT
+            else {
+                $self->Unix(
+                         timegm( $sec, $min, $hours, $mday, $mon, $year ) );
             }
+
+            $self->Unix(-1) unless $self->Unix;
         }
         else {
-            use Carp;
+            require Carp;
             Carp::cluck;
             $RT::Logger->debug(
                      "Couldn't parse date $args{'Value'} as a $args{'Format'}");
@@ -235,7 +230,7 @@
         my $date = Time::ParseDate::parsedate($args{'Value'},
                         UK => $RT::DateDayBeforeMonth,
                         PREFER_PAST => $RT::AmbiguousDayInPast,
-                        PREFER_FUTURE => !($RT::AmbiguousDayInPast));
+                        PREFER_FUTURE => !$RT::AmbiguousDayInPast );
 
         #This date has now been set to a date in the _local_ timezone.
         #since ISO dates are known to be in GMT (for RT's purposes);
@@ -297,7 +292,7 @@
     my $self = shift;
     my $other = shift;
 
-    if (UNIVERSAL::isa($other => 'RT::Date')) {
+    if ( UNIVERSAL::isa( $other, 'RT::Date' ) ) {
         $other=$other->Unix;
     }
     return ($self->Unix - $other);
@@ -319,7 +314,6 @@
     my $self = shift;
     my $other = shift;
 
-
     if ($other < 1) {
         return ("");
     }


More information about the Rt-commit mailing list