[Rt-commit] rt branch, cf-date, updated. rt-3.8.8-197-gfe0ee79

? sunnavy sunnavy at bestpractical.com
Wed Aug 4 20:25:21 EDT 2010


The branch, cf-date has been updated
       via  fe0ee7915be9eb9d35dcceb6521724ab8b6e460f (commit)
      from  6633f23ca23ab371e48cd4b2994ec6a9be228c45 (commit)

Summary of changes:
 lib/RT/CustomField_Overlay.pm |   38 +++++++++++++++++++-------------------
 1 files changed, 19 insertions(+), 19 deletions(-)

- Log -----------------------------------------------------------------
commit fe0ee7915be9eb9d35dcceb6521724ab8b6e460f
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Aug 5 08:26:24 2010 +0800

    code tweak: split into 2 blocks to handle Date/DateTime, respectively

diff --git a/lib/RT/CustomField_Overlay.pm b/lib/RT/CustomField_Overlay.pm
index 0de811b..28114d8 100755
--- a/lib/RT/CustomField_Overlay.pm
+++ b/lib/RT/CustomField_Overlay.pm
@@ -1172,27 +1172,27 @@ sub AddValueForObject {
         }
     }
     # For date, we need to store Content as ISO date
-    if ($self->Type =~ /^Date(Time)?$/) {
-        my $is_datetime = $1 ? 1 : 0; 
+    if ( $self->Type eq 'DateTime' ) {
         my $DateObj = new RT::Date( $self->CurrentUser );
-        if ($is_datetime) {
-            $DateObj->Set(
-                Format => 'unknown',
-                Value  => $args{'Content'},
-            );
-            $args{'Content'} = $DateObj->ISO;
-        }
-        else {
-            # in case user input date with time, let's omit it by setting timezone 
-            # to utc so "hour" won't affect "day"
-            $DateObj->Set(
-                Format => 'unknown',
-                Value  => $args{'Content'},
-                Timezone => 'UTC',
-            );
-            $args{'Content'} = $DateObj->Date( Timezone => 'UTC' );
-        }
+        $DateObj->Set(
+            Format => 'unknown',
+            Value  => $args{'Content'},
+        );
+        $args{'Content'} = $DateObj->ISO;
+    }
+    elsif ( $self->Type eq 'Date' ) {
+
+        # in case user input date with time, let's omit it by setting timezone
+        # to utc so "hour" won't affect "day"
+        my $DateObj = new RT::Date( $self->CurrentUser );
+        $DateObj->Set(
+            Format   => 'unknown',
+            Value    => $args{'Content'},
+            Timezone => 'UTC',
+        );
+        $args{'Content'} = $DateObj->Date( Timezone => 'UTC' );
     }
+
     my $newval = RT::ObjectCustomFieldValue->new( $self->CurrentUser );
     my $val    = $newval->Create(
         ObjectType   => ref($obj),

-----------------------------------------------------------------------


More information about the Rt-commit mailing list