[Rt-commit] rt branch, 4.0/cf-date-parse-in-search, updated. rt-4.0.2-122-g5ddb2fc

? sunnavy sunnavy at bestpractical.com
Wed Oct 5 03:35:51 EDT 2011


The branch, 4.0/cf-date-parse-in-search has been updated
       via  5ddb2fc643d2ca8306689b86db7ecddb8a02ea4c (commit)
      from  0bae7ff1295ec406b4a490eaf77977573f167895 (commit)

Summary of changes:
 lib/RT/Tickets.pm |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

- Log -----------------------------------------------------------------
commit 5ddb2fc643d2ca8306689b86db7ecddb8a02ea4c
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Oct 5 14:50:25 2011 +0800

    better way to distinguish between date and datetime
    
    i.e.
    1. "today", "tomorrow" and "yesterday" are of type date.
    2. unless there is "hh:mm:ss" or "midnight" in string, as long as the parsed time
    is at midnight(00:00:00), it's a date.

diff --git a/lib/RT/Tickets.pm b/lib/RT/Tickets.pm
index 6fdbef4..80f5e95 100644
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@ -1520,8 +1520,12 @@ sub _CustomFieldLimit {
         if ( $date->Unix ) {
 
             # don't consider tz for Date, use server's all the time.
-            if (   $cf->Type eq 'Date'
-                || $value !~ /:|am|pm|hours|minutes|seconds/i )
+            if (
+                   $cf->Type eq 'Date'
+                || $value =~ /^\s*(?:today|tomorrow|yesterday)\s*$/i
+                || (   $value !~ /midnight|\d+:\d+:\d+/i
+                    && $date->Time( Timezone => 'user' ) eq '00:00:00' )
+              )
             {
                 $value = $date->Date( Timezone => 'server' );
             }

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


More information about the Rt-commit mailing list