[jsword-svn] r1284 - trunk/jsword/src/main/java/org/crosswire/jsword/book/sword

dmsmith at www.crosswire.org dmsmith at www.crosswire.org
Fri Apr 20 10:50:32 MST 2007


Author: dmsmith
Date: 2007-04-20 10:50:32 -0700 (Fri, 20 Apr 2007)
New Revision: 1284

Modified:
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawLDBackend.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZLDBackend.java
Log:
Fixed a bug where the Daily Devotional would not go to the current day.

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawLDBackend.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawLDBackend.java	2007-04-20 17:32:41 UTC (rev 1283)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawLDBackend.java	2007-04-20 17:50:32 UTC (rev 1284)
@@ -25,7 +25,6 @@
 import java.io.IOException;
 import java.io.RandomAccessFile;
 import java.text.DateFormat;
-import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.GregorianCalendar;
 
@@ -138,10 +137,10 @@
         Key reply = new DefaultKeyList(null, bmd.getName());
 
         boolean isDailyDevotional = bmd.getBookCategory().equals(BookCategory.DAILY_DEVOTIONS);
-        // We use 1972 because it is a leap year.
-        Calendar greg = new GregorianCalendar(1972, Calendar.JANUARY, 1);
-        DateFormat nameDF = new SimpleDateFormat("d MMMM"); //$NON-NLS-1$
 
+        Calendar greg = new GregorianCalendar();
+        DateFormat nameDF = DateFormat.getDateInstance(DateFormat.MEDIUM);
+
         int entrysize = OFFSETSIZE + datasize;
         long entries;
         try
@@ -208,6 +207,15 @@
 
                 Key key = new IndexKey(keytitle, offset, size, reply);
 
+                // remove duplicates, keeping later one.
+                // This occurs under some conditions:
+                // For daily devotionals where 02.29 becomes calendarized to Mar 1 for non-leap years
+                // For modules that have been updated by appending new data.
+                if (reply.contains(key))
+                {
+                    reply.removeAll(key);
+                }
+
                 reply.addAll(key);
             }
             catch (IOException ex)

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZLDBackend.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZLDBackend.java	2007-04-20 17:32:41 UTC (rev 1283)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZLDBackend.java	2007-04-20 17:50:32 UTC (rev 1284)
@@ -25,7 +25,6 @@
 import java.io.IOException;
 import java.io.RandomAccessFile;
 import java.text.DateFormat;
-import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.GregorianCalendar;
 
@@ -205,10 +204,10 @@
         keys = new DefaultKeyList(null, bmd.getName());
 
         boolean isDailyDevotional = bmd.getBookCategory().equals(BookCategory.DAILY_DEVOTIONS);
-        // We use 1972 because it is a leap year.
-        Calendar greg = new GregorianCalendar(1972, Calendar.JANUARY, 1);
-        DateFormat nameDF = new SimpleDateFormat("d MMMM"); //$NON-NLS-1$
 
+        Calendar greg = new GregorianCalendar();
+        DateFormat nameDF = DateFormat.getDateInstance(DateFormat.MEDIUM);
+
         long entries;
         try
         {
@@ -261,6 +260,15 @@
 
                 Key key = new IndexKey(keytitle, offset, size, keys);
 
+                // remove duplicates, keeping later one.
+                // This occurs under some conditions:
+                // For daily devotionals where 02.29 becomes calendarized to Mar 1 for non-leap years
+                // For modules that have been updated by appending new data.
+                if (keys.contains(key))
+                {
+                    keys.removeAll(key);
+                }
+
                 keys.addAll(key);
             }
             catch (IOException ex)




More information about the jsword-svn mailing list