james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject james-mime4j git commit: JAMES-2045 DateTimeFieldImpl should assume 19xx century when date without century >= 70
Date Tue, 06 Jun 2017 08:10:51 GMT
Repository: james-mime4j
Updated Branches:
  refs/heads/master e32e83fbc -> 7a54eebe7


JAMES-2045 DateTimeFieldImpl should assume 19xx century when date without century >= 70


Project: http://git-wip-us.apache.org/repos/asf/james-mime4j/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-mime4j/commit/7a54eebe
Tree: http://git-wip-us.apache.org/repos/asf/james-mime4j/tree/7a54eebe
Diff: http://git-wip-us.apache.org/repos/asf/james-mime4j/diff/7a54eebe

Branch: refs/heads/master
Commit: 7a54eebe73a582ee9ead995a4e783d3e190fcf47
Parents: e32e83f
Author: benwa <btellier@linagora.com>
Authored: Mon Jun 5 18:03:53 2017 +0700
Committer: benwa <btellier@linagora.com>
Committed: Mon Jun 5 18:03:53 2017 +0700

----------------------------------------------------------------------
 .../apache/james/mime4j/field/datetime/DateTimeParser.jj  |  4 ++++
 .../apache/james/mime4j/field/DateTimeFieldImplTest.java  |  6 ++++++
 .../apache/james/mime4j/field/datetime/DateTimeTest.java  | 10 +++++-----
 3 files changed, 15 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-mime4j/blob/7a54eebe/dom/src/main/javacc/org/apache/james/mime4j/field/datetime/DateTimeParser.jj
----------------------------------------------------------------------
diff --git a/dom/src/main/javacc/org/apache/james/mime4j/field/datetime/DateTimeParser.jj
b/dom/src/main/javacc/org/apache/james/mime4j/field/datetime/DateTimeParser.jj
index 7b9b490..dc110ca 100644
--- a/dom/src/main/javacc/org/apache/james/mime4j/field/datetime/DateTimeParser.jj
+++ b/dom/src/main/javacc/org/apache/james/mime4j/field/datetime/DateTimeParser.jj
@@ -230,6 +230,10 @@ String year() :
       String year = (String) t.image;
       if (year.length() == 2) 
       {
+        if (year.charAt(0) > '6')
+        {
+          return "19" + year;
+        }
         return "20" + year;
       }
       return year;

http://git-wip-us.apache.org/repos/asf/james-mime4j/blob/7a54eebe/dom/src/test/java/org/apache/james/mime4j/field/DateTimeFieldImplTest.java
----------------------------------------------------------------------
diff --git a/dom/src/test/java/org/apache/james/mime4j/field/DateTimeFieldImplTest.java b/dom/src/test/java/org/apache/james/mime4j/field/DateTimeFieldImplTest.java
index 0e13b2d..45bff87 100644
--- a/dom/src/test/java/org/apache/james/mime4j/field/DateTimeFieldImplTest.java
+++ b/dom/src/test/java/org/apache/james/mime4j/field/DateTimeFieldImplTest.java
@@ -60,6 +60,12 @@ public class DateTimeFieldImplTest {
     }
 
     @Test
+    public void parseShouldAddPreviousCenturyWhen2DigitsAndMoreThan70s() throws Exception
{
+        DateTimeField field = parse("Date: Wed, 13 May 87 14:18:52Z");
+        assertEquals("Wed May 13 14:18:52 UTC 1987", field.getDate().toString());
+    }
+
+    @Test
     public void dayIsDependentFromTheDateNotFromTheGivenDay() throws Exception {
         DateTimeField field = parse("Date: Mon, 13 May 17 14:18:52Z");
         assertEquals("Sat May 13 14:18:52 UTC 2017", field.getDate().toString());

http://git-wip-us.apache.org/repos/asf/james-mime4j/blob/7a54eebe/dom/src/test/java/org/apache/james/mime4j/field/datetime/DateTimeTest.java
----------------------------------------------------------------------
diff --git a/dom/src/test/java/org/apache/james/mime4j/field/datetime/DateTimeTest.java b/dom/src/test/java/org/apache/james/mime4j/field/datetime/DateTimeTest.java
index 685281b..02510ba 100644
--- a/dom/src/test/java/org/apache/james/mime4j/field/datetime/DateTimeTest.java
+++ b/dom/src/test/java/org/apache/james/mime4j/field/datetime/DateTimeTest.java
@@ -44,12 +44,12 @@ public class DateTimeTest {
 
 
         ensureAllEqual(new String[]{
-                "Fri, 21 Nov 2097 09:55:06 -0600", // baseline
+                "Fri, 21 Nov 1997 09:55:06 -0600", // baseline
                 "Fri, 21 Nov 97 09:55:06 -0600",   // 2-digit year
-                "Fri, 21 Nov 197 09:55:06 -0600",  // 3-digit year
-                "Fri, 21 Nov 2097 10:55:06 -0500", // shift time zone
-                "Fri, 21 Nov 2097 19:25:06 +0330", // shift time zone
-                "21 Nov 2097 09:55:06 -0600"       // omit day of week
+                "Fri, 21 Nov 097 09:55:06 -0600",  // 3-digit year
+                "Fri, 21 Nov 1997 10:55:06 -0500", // shift time zone
+                "Fri, 21 Nov 1997 19:25:06 +0330", // shift time zone
+                "21 Nov 1997 09:55:06 -0600"       // omit day of week
         });
 
         ensureAllEqual(new String[]{


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message