You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2008/02/07 13:39:14 UTC

svn commit: r619382 - in /poi/trunk/src: documentation/content/xdocs/changes.xml documentation/content/xdocs/status.xml java/org/apache/poi/hssf/usermodel/HSSFDateUtil.java testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java

Author: nick
Date: Thu Feb  7 04:39:12 2008
New Revision: 619382

URL: http://svn.apache.org/viewvc?rev=619382&view=rev
Log:
Patch from bug #44373 - Have HSSFDateUtil.isADateFormat support more date formats

Modified:
    poi/trunk/src/documentation/content/xdocs/changes.xml
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFDateUtil.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java

Modified: poi/trunk/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/changes.xml?rev=619382&r1=619381&r2=619382&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/changes.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/changes.xml Thu Feb  7 04:39:12 2008
@@ -36,6 +36,7 @@
 
 		<!-- Don't forget to update status.xml too! -->
         <release version="3.1-beta1" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">44373 - Have HSSFDateUtil.isADateFormat recognize more formats as being dates</action>
            <action dev="POI-DEVELOPERS" type="add">37923 - Support for Excel hyperlinks</action>
            <action dev="POI-DEVELOPERS" type="add">Implement hashCode() and equals(obj) on HSSFFont and HSSFCellStyle</action>
            <action dev="POI-DEVELOPERS" type="fix">44345 - Implement CountA, CountIf, Index, Rows and Columns functions</action>

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=619382&r1=619381&r2=619382&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Thu Feb  7 04:39:12 2008
@@ -33,6 +33,7 @@
 	<!-- Don't forget to update changes.xml too! -->
     <changes>
         <release version="3.1-beta1" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">44373 - Have HSSFDateUtil.isADateFormat recognize more formats as being dates</action>
            <action dev="POI-DEVELOPERS" type="add">37923 - Support for Excel hyperlinks</action>
            <action dev="POI-DEVELOPERS" type="add">Implement hashCode() and equals(obj) on HSSFFont and HSSFCellStyle</action>
            <action dev="POI-DEVELOPERS" type="fix">44345 - Implement CountA, CountIf, Index, Rows and Columns functions</action>

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFDateUtil.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFDateUtil.java?rev=619382&r1=619381&r2=619382&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFDateUtil.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFDateUtil.java Thu Feb  7 04:39:12 2008
@@ -208,9 +208,9 @@
     	//  who knows what that starting bit is all about
     	fs = fs.replaceAll("\\[\\$\\-.*?\\]", "");
     	
-    	// Otherwise, check it's only made up of:
-    	//  y m d - / ,
-    	if(fs.matches("^[ymd\\-/, ]+$")) {
+    	// Otherwise, check it's only made up, in any case, of:
+    	//  y m d h s - / , . :
+    	if(fs.matches("^[yYmMdDhHsS\\-/,. :]+$")) {
     		return true;
     	}
     	

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java?rev=619382&r1=619381&r2=619382&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java Thu Feb  7 04:39:12 2008
@@ -228,6 +228,7 @@
     			"yyyy-mm-dd", "yyyy/mm/dd", "yy/mm/dd", "yy/mmm/dd",
     			"dd/mm/yy", "dd/mm/yyyy", "dd/mmm/yy",
     			"dd-mm-yy", "dd-mm-yyyy",
+    			"DD-MM-YY", "DD-mm-YYYY",
     			"dd\\-mm\\-yy", // Sometimes escaped
     			
     			// These crazy ones are valid
@@ -242,15 +243,33 @@
     		assertTrue( HSSFDateUtil.isADateFormat(formatId, formats[i]) );
     	}
     	
+    	// Then time based ones too
+    	formats = new String[] {
+    			"yyyy-mm-dd hh:mm:ss", "yyyy/mm/dd HH:MM:SS", 
+    			"mm/dd HH:MM", "yy/mmm/dd SS",
+    	};
+    	for(int i=0; i<formats.length; i++) {
+    		assertTrue( HSSFDateUtil.isADateFormat(formatId, formats[i]) );
+    	}
+    	
     	// Then invalid ones
     	formats = new String[] {
-    			"yyyy:mm:dd", 
+    			"yyyy*mm*dd", 
     			"0.0", "0.000",
     			"0%", "0.0%",
     			"", null
     	};
     	for(int i=0; i<formats.length; i++) {
     		assertFalse( HSSFDateUtil.isADateFormat(formatId, formats[i]) );
+    	}
+    	
+    	// And these are ones we probably shouldn't allow,
+    	//  but would need a better regexp
+    	formats = new String[] {
+    			"yyyy:mm:dd", 
+    	};
+    	for(int i=0; i<formats.length; i++) {
+    	//	assertFalse( HSSFDateUtil.isADateFormat(formatId, formats[i]) );
     	}
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org