[Rt-commit] rt branch, master, updated. rt-4.2.12-370-g4836a20

Shawn Moore shawn at bestpractical.com
Fri Oct 30 12:06:17 EDT 2015


The branch, master has been updated
       via  4836a20e8c90594f025a30a43bee32c050300e2b (commit)
      from  837228ce3190a74c7c6a8e2937e2a3e728a644ca (commit)

Summary of changes:
 etc/RT_Config.pm.in | 23 +++++++++++++++++++++++
 lib/RT/Date.pm      | 14 +++++++++++++-
 2 files changed, 36 insertions(+), 1 deletion(-)

- Log -----------------------------------------------------------------
commit 4836a20e8c90594f025a30a43bee32c050300e2b
Author: Christian Loos <cloos at netcologne.de>
Date:   Tue Oct 27 11:03:50 2015 +0100

    new $PreferDateTimeFormatNatural config option

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index d92b6a0..47315ab 100644
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -2460,6 +2460,29 @@ This option can also be set as an individual user preference.
 
 Set($TimeInICal, 0);
 
+=item C<$PreferDateTimeFormatNatural>
+
+By default, RT parses an unknown date first with L<Time::ParseDate>, and if
+this fails with L<DateTime::Format::Natural>.
+C<$PreferDateTimeFormatNatural> changes this behavior to first parse with
+L<DateTime::Format::Natural>, and if this fails with L<Time::ParseDate>.
+This gives you the possibility to use the more advanced features of
+L<DateTime::Format::Natural>.
+For example with L<Time::ParseDate> it isn't possible to get the
+'first day of the last month', where L<DateTime::Format::Natural> supports
+this with 'last month'.
+
+Be aware that L<Time::ParseDate> and L<DateTime::Format::Natural> have
+different definitions for the relative date and time syntax.
+L<Time::ParseDate> returns for 'last month' this DayOfMonth from the last month.
+L<DateTime::Format::Natural> returns for 'last month' the first day of the last
+month. So changing this config option maybe changes the results of your saved
+searches.
+
+=cut
+
+Set($PreferDateTimeFormatNatural, 0);
+
 =back
 
 =head1 Cryptography
diff --git a/lib/RT/Date.pm b/lib/RT/Date.pm
index d09411c..57b02b2 100644
--- a/lib/RT/Date.pm
+++ b/lib/RT/Date.pm
@@ -213,7 +213,19 @@ sub Set {
         }
     }
     elsif ( $format eq 'unknown' ) {
-        return $self->Unix($self->ParseByTimeParseDate(%args) || $self->ParseByDateTimeFormatNatural(%args) || 0);
+        if ( RT->Config->Get('PreferDateTimeFormatNatural') ) {
+            return $self->Unix(
+                   $self->ParseByDateTimeFormatNatural(%args)
+                || $self->ParseByTimeParseDate(%args)
+                || 0
+            );
+        } else {
+            return $self->Unix(
+                   $self->ParseByTimeParseDate(%args)
+                || $self->ParseByDateTimeFormatNatural(%args)
+                || 0
+            );
+        }
     }
     else {
         $RT::Logger->error(

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


More information about the rt-commit mailing list