[rt-devel] RT 2.1.64, my findings and a new translation file

Phil Homewood pdh at snapgear.com
Sun Feb 2 19:49:47 EST 2003


THAUVIN Blaise (Dir. Informatique) wrote:
>       Dates : The dates field does not understand localized formats. This
> will lead to lots of mistakes in Europe : when I enter 2/1/2003, I mean 2nd
> of january, but RT understands 1st of February.

Throw out the last patch I sent to rt-devel and apply this
one. You should then be able to make RT understand sensible
date formats by tweaking RT_Config.pm. Actually, sensible is
the default if you apply this; if you want broken you should
change $DateDayBeforeMonth to 0. :-)

-- 
Phil Homewood, Systems Janitor, www.SnapGear.com
pdh at snapgear.com Ph: +61 7 3435 2810 Fx: +61 7 3891 3630
SnapGear - Custom Embedded Solutions and Security Appliances
-------------- next part --------------
diff -ur rt-2-1-66-orig/etc/RT_Config.pm.in rt-2-1-66/etc/RT_Config.pm.in
--- rt-2-1-66-orig/etc/RT_Config.pm.in	2003-02-02 17:47:01.000000000 +1000
+++ rt-2-1-66/etc/RT_Config.pm.in	2003-02-03 10:41:31.000000000 +1000
@@ -363,4 +363,32 @@
 
 # }}}
 
+# {{{ RT Date Handling Options (for Time::ParseDate)
+
+# Set this to 1 if your local date convention looks like "dd/mm/yy"
+# instead of "mm/dd/yy".
+
+$DateDayBeforeMonth = 1;
+
+# Should "Tuesday" default to meaning "Next Tuesday" or "Last Tuesday"?
+# Set to 0 for "Next" or 1 for "Last".
+
+$AmbiguousDayInPast = 1;
+
+# }}}
+
+# {{{ RT Date Handling Options (for Time::ParseDate)
+
+# Set this to 1 if your local date convention looks like "dd/mm/yy"
+# instead of "mm/dd/yy".
+
+$DateDayBeforeMonth = 1;
+
+# Should "Tuesday" default to meaning "Next Tuesday" or "Last Tuesday"?
+# Set to 0 for "Next" or 1 for "Last".
+
+$AmbiguousDayInPast = 1;
+
+# }}}
+
 1;
Only in rt-2-1-66/etc: RT_Config.pm.in.orig
diff -ur rt-2-1-66-orig/lib/RT/Date.pm rt-2-1-66/lib/RT/Date.pm
--- rt-2-1-66-orig/lib/RT/Date.pm	2003-02-02 17:47:04.000000000 +1000
+++ rt-2-1-66/lib/RT/Date.pm	2003-02-03 10:44:20.000000000 +1000
@@ -90,10 +90,10 @@
 
 If $args->{'Format'} is ISO, tries to parse an ISO date.
 
-If $args->{'Format'} is 'unknown', require Date::Parse and make it figure things
-out. This is a heavyweight operation that should never be called from within 
-RT's core. But it's really useful for something like the textbox date entry
-where we let the user do whatever they want.
+If $args->{'Format'} is 'unknown', require Time::ParseDate and make it figure
+things out. This is a heavyweight operation that should never be called from
+within RT's core. But it's really useful for something like the textbox date
+entry where we let the user do whatever they want.
 
 If $args->{'Value'}  is 0, assumes you mean never.
 
@@ -174,11 +174,14 @@
         }
     }
     elsif ( $args{'Format'} =~ /^unknown$/i ) {
-        require Date::Parse;
+        require Time::ParseDate;
 
         #Convert it to an ISO format string
 
-        my $date = Date::Parse::str2time( $args{'Value'} );
+	my $date = Time::ParseDate::parsedate($args{'Value'},
+			UK => $RT::DateDayBeforeMonth,
+			PREFER_PAST => $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);
diff -ur rt-2-1-66-orig/lib/RT/Tickets_Overlay.pm rt-2-1-66/lib/RT/Tickets_Overlay.pm
--- rt-2-1-66-orig/lib/RT/Tickets_Overlay.pm	2003-02-02 17:47:06.000000000 +1000
+++ rt-2-1-66/lib/RT/Tickets_Overlay.pm	2003-02-03 10:46:13.000000000 +1000
@@ -350,10 +350,13 @@
   die "Incorrect Meta Data for $field"
     unless (defined $meta->[1]);
 
-  use Date::Parse;
+  require Time::ParseDate;
   use POSIX 'strftime';
 
-  my $time = str2time($value);
+  my $time = Time::ParseDate::parsedate( $value,
+			UK => $RT::DateDayBeforeMonth,
+			PREFER_PAST => $RT::AmbiguousDayInPast,
+			PREFER_FUTURE => !($RT::AmbiguousDayInPast));
   $value = strftime("%Y-%m-%d %H:%M",localtime($time));
 
   $sb->_SQLLimit(
@@ -393,7 +396,7 @@
 
 Handle fields limiting based on Transaction Date.
 
-The inpupt value must be in a format parseable by Date::Parse
+The inpupt value must be in a format parseable by Time::ParseDate
 
 Meta Data:
   None


More information about the Rt-devel mailing list