You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by ni...@apache.org on 2006/04/05 13:44:31 UTC

svn commit: r391591 - in /jakarta/poi/trunk/src/scratchpad: src/org/apache/poi/hslf/util/ testcases/org/apache/poi/hslf/record/ testcases/org/apache/poi/hslf/util/

Author: nick
Date: Wed Apr  5 04:44:28 2006
New Revision: 391591

URL: http://svn.apache.org/viewcvs?rev=391591&view=rev
Log:
Fix for 12 vs 24 hour times

Modified:
    jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/util/SystemTimeUtils.java
    jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestComment2000.java
    jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestComment2000Atom.java
    jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/util/TestSystemTimeUtils.java

Modified: jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/util/SystemTimeUtils.java
URL: http://svn.apache.org/viewcvs/jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/util/SystemTimeUtils.java?rev=391591&r1=391590&r2=391591&view=diff
==============================================================================
--- jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/util/SystemTimeUtils.java (original)
+++ jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/util/SystemTimeUtils.java Wed Apr  5 04:44:28 2006
@@ -50,10 +50,10 @@
         
         cal.set(Calendar.YEAR,         LittleEndian.getShort(data,offset));
         cal.set(Calendar.MONTH,        LittleEndian.getShort(data,offset+2)-1);
-        // Not actually needed 0 - can be found from day of month 
+        // Not actually needed - can be found from day of month 
         //cal.set(Calendar.DAY_OF_WEEK,  LittleEndian.getShort(data,offset+4)+1);
         cal.set(Calendar.DAY_OF_MONTH, LittleEndian.getShort(data,offset+6));
-        cal.set(Calendar.HOUR,         LittleEndian.getShort(data,offset+8));
+        cal.set(Calendar.HOUR_OF_DAY,  LittleEndian.getShort(data,offset+8));
         cal.set(Calendar.MINUTE,       LittleEndian.getShort(data,offset+10));
         cal.set(Calendar.SECOND,       LittleEndian.getShort(data,offset+12));
         cal.set(Calendar.MILLISECOND,  LittleEndian.getShort(data,offset+14));
@@ -80,7 +80,7 @@
         LittleEndian.putShort(dest, offset + 2, (short)(cal.get(Calendar.MONTH) + 1));
         LittleEndian.putShort(dest, offset + 4, (short)(cal.get(Calendar.DAY_OF_WEEK)-1));
         LittleEndian.putShort(dest, offset + 6, (short) cal.get(Calendar.DAY_OF_MONTH));
-        LittleEndian.putShort(dest, offset + 8, (short) cal.get(Calendar.HOUR));
+        LittleEndian.putShort(dest, offset + 8, (short) cal.get(Calendar.HOUR_OF_DAY));
         LittleEndian.putShort(dest, offset + 10,(short) cal.get(Calendar.MINUTE));
         LittleEndian.putShort(dest, offset + 12,(short) cal.get(Calendar.SECOND));
         LittleEndian.putShort(dest, offset + 14,(short) cal.get(Calendar.MILLISECOND));

Modified: jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestComment2000.java
URL: http://svn.apache.org/viewcvs/jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestComment2000.java?rev=391591&r1=391590&r2=391591&view=diff
==============================================================================
--- jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestComment2000.java (original)
+++ jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestComment2000.java Wed Apr  5 04:44:28 2006
@@ -79,7 +79,7 @@
 		0x48, 00,
 		00, 00, 0xE1-256, 0x2E, 0x1C, 00, 00, 00,
 		01, 00, 00, 00, 0xD6-256, 0x07, 01, 00, 
-		02, 00, 0x18, 00, 0x0A, 00, 0x19, 00, 03,
+		02, 00, 0x18, 00, 0x16, 00, 0x19, 00, 03,
 		00, 0xD5-256, 02, 0x0A, 00, 00, 00, 
 		0x0A, 00, 00, 00
 		};
@@ -106,8 +106,18 @@
 		assertEquals(1, c2a.getNumber());
 		assertEquals(0x92, c2a.getXOffset());
 		assertEquals(0x92, c2a.getYOffset());
-		Date exp_a = sdf.parse("2006-01-24 22:26:15.205");
+		Date exp_a = sdf.parse("2006-01-24 10:26:15.205");
 		assertEquals(exp_a, c2a.getDate());
+	}
+	public void testCommentAtomB() throws Exception {
+		Comment2000 cb = new Comment2000(data_b, 0, data_b.length);
+		Comment2000Atom c2b = cb.getComment2000Atom();
+		
+		assertEquals(1, c2b.getNumber());
+		assertEquals(0x0a, c2b.getXOffset());
+		assertEquals(0x0a, c2b.getYOffset());
+		Date exp_b = sdf.parse("2006-01-24 22:25:03.725");
+		assertEquals(exp_b, c2b.getDate());
 	}
 
 	public void testWrite() throws Exception {

Modified: jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestComment2000Atom.java
URL: http://svn.apache.org/viewcvs/jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestComment2000Atom.java?rev=391591&r1=391590&r2=391591&view=diff
==============================================================================
--- jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestComment2000Atom.java (original)
+++ jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestComment2000Atom.java Wed Apr  5 04:44:28 2006
@@ -42,7 +42,7 @@
 	private byte[] data_b = new byte[] { 
 		00, 00, 0xE1-256, 0x2E, 0x1C, 00, 00, 00,
 		05, 00, 00, 00, 0xD6-256, 0x07, 01, 00, 
-		02, 00, 0x18, 00, 0x0A, 00, 0x19, 00, 03,
+		02, 00, 0x18, 00, 0x15, 00, 0x19, 00, 03,
 		00, 0xD5-256, 02, 0x0A, 00, 00, 00, 
 		0x0E, 00, 00, 00
 		};
@@ -58,10 +58,10 @@
 		Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
 		Comment2000Atom cb = new Comment2000Atom(data_b, 0, data_b.length);
 
-    	// A is 2006-01-24 (2nd day of week) 22:26:15.205
-		Date exp_a = sdf.parse("2006-01-24 22:26:15.205");
-		// B is 2006-01-24 (2nd day of week) 22:25:03.725
-		Date exp_b = sdf.parse("2006-01-24 22:25:03.725");
+    	// A is 2006-01-24 (2nd day of week) 20:26:15.205
+		Date exp_a = sdf.parse("2006-01-24 10:26:15.205");
+		// B is 2006-01-24 (2nd day of week) 21:25:03.725
+		Date exp_b = sdf.parse("2006-01-24 21:25:03.725");
 		
 		assertEquals(exp_a, ca.getDate());
 		assertEquals(exp_b, cb.getDate());
@@ -112,7 +112,7 @@
     	a.setYOffset(0x92);
     	
     	// Set the date
-		Date date_a = sdf.parse("2006-01-24 22:26:15.205");
+		Date date_a = sdf.parse("2006-01-24 10:26:15.205");
 		a.setDate(date_a);
 		
 		// Check it's now the same as a
@@ -134,7 +134,7 @@
 		ca.setNumber(5);
 		
 		// Change the date
-		Date new_date = sdf.parse("2006-01-24 22:25:03.725");
+		Date new_date = sdf.parse("2006-01-24 21:25:03.725");
 		ca.setDate(new_date);
 		
 		// Change the x and y

Modified: jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/util/TestSystemTimeUtils.java
URL: http://svn.apache.org/viewcvs/jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/util/TestSystemTimeUtils.java?rev=391591&r1=391590&r2=391591&view=diff
==============================================================================
--- jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/util/TestSystemTimeUtils.java (original)
+++ jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/util/TestSystemTimeUtils.java Wed Apr  5 04:44:28 2006
@@ -40,7 +40,7 @@
 	private byte[] data_b = new byte[] {
 		00, 00, 0xE1-256, 0x2E, 0x1C, 00, 00, 00,
 		01, 00, 00, 00, 0xD6-256, 0x07, 01, 00, 
-		02, 00, 0x18, 00, 0x0A, 00, 0x19, 00, 03,
+		02, 00, 0x18, 00, 0x15, 00, 0x19, 00, 03,
 		00, 0xD5-256, 02, 0x0A, 00, 00, 00, 
 		0x0A, 00, 00, 00
 	};
@@ -50,8 +50,8 @@
 	public void testGetDateA() throws Exception {
 		Date date = SystemTimeUtils.getDate(data_a);
 		
-		// Is 2006-01-24 (2nd day of week) 22:26:15.205
-		Date exp = sdf.parse("2006-01-24 22:26:15.205");
+		// Is 2006-01-24 (2nd day of week) 10:26:15.205
+		Date exp = sdf.parse("2006-01-24 10:26:15.205");
 		assertEquals(exp.getTime(), date.getTime());
 		assertEquals(exp, date);
 	}
@@ -59,15 +59,15 @@
 	public void testGetDateB() throws Exception {
 		Date date = SystemTimeUtils.getDate(data_b, 8+4);
 		
-		// Is 2006-01-24 (2nd day of week) 22:25:03.725
-		Date exp = sdf.parse("2006-01-24 22:25:03.725");
+		// Is 2006-01-24 (2nd day of week) 21:25:03.725
+		Date exp = sdf.parse("2006-01-24 21:25:03.725");
 		assertEquals(exp.getTime(), date.getTime());
 		assertEquals(exp, date);
 	}
 	
 	public void testWriteDateA() throws Exception {
 		byte[] out_a = new byte[data_a.length];
-		Date date = sdf.parse("2006-01-24 22:26:15.205");
+		Date date = sdf.parse("2006-01-24 10:26:15.205");
 		SystemTimeUtils.storeDate(date, out_a);
 		
 		for(int i=0; i<out_a.length; i++) {
@@ -81,7 +81,7 @@
 		System.arraycopy(data_b, 0, out_b, 0, 12);
 		System.arraycopy(data_b, 12+16, out_b, 12+16, data_b.length-12-16);
 		
-		Date date = sdf.parse("2006-01-24 22:25:03.725");
+		Date date = sdf.parse("2006-01-24 21:25:03.725");
 		SystemTimeUtils.storeDate(date, out_b, 12);
 		
 		for(int i=0; i<out_b.length; i++) {



---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/