w3cdate parsing fix
authorzapata <zapata>
Tue, 24 Jun 2003 03:52:22 +0000 (03:52 +0000)
committerzapata <zapata>
Tue, 24 Jun 2003 03:52:22 +0000 (03:52 +0000)
source/mir/rss/RSSTest.java
source/mir/util/DateTimeFunctions.java
source/mir/util/StringRoutines.java

index bcfd786..92f102c 100755 (executable)
@@ -40,7 +40,7 @@ public class RSSTest {
   public static void main(String[] args) {
 
     RSSReader reader = new RSSReader();
-    RSS091Reader reader2 = new RSS091Reader();
+//..    RSS091Reader reader2 = new RSS091Reader();
     try {
 //      RE test = new RE(".*\\bLB\\b.*", RE.REG_ICASE);
 //      System.out.println(" LB II : " + test.isMatch("LB II"));
@@ -48,8 +48,8 @@ public class RSSTest {
 //      System.out.println(" revised LB II : " + test.isMatch("revised LB II"));
 //      System.out.println(" buLB: " + test.isMatch("buLB"));
 
-      RSSData nl = reader.parseUrl("http://www.indymedia.nl/features.1-0.rdf");
-      RSSData it = reader.parseUrl("http://g8.mir.dnsalias.net/italynewswire.rss");
+      RSSData nl = reader.parseUrl("http://biotechdev.mir.dnsalias.net/test.rss");
+//      RSSData it = reader.parseUrl("http://g8.mir.dnsalias.net/italynewswire.rss");
 //      Object result = StructuredContentParser.parse(" { a = 'b' 'as a' = [ 'asd' asd 'asdas asd as''asd' ] }") ;
 //      System.out.println("" + wvl.get("rss:item"));
 //      RSSData fr = reader2.parseUrl("http://paris.indymedia.org/backendg8.php3");
index e77e227..367240a 100755 (executable)
@@ -76,6 +76,8 @@ public class DateTimeFunctions {
       int millisecond = 0;
       int houroffset = 0;
       int minuteoffset = 0;
+      boolean negativeOffset = false;
+
 
       SimpleParser parser = new SimpleParser(aString.trim());
       String part = parser.parse(NUMBER);
@@ -122,25 +124,26 @@ public class DateTimeFunctions {
                 }
 
                 if (sign.equals("-")) {
-                  houroffset = -houroffset;
-                  minuteoffset = - minuteoffset;
+                  negativeOffset=true;
                 }
               }
             }
-
-
           }
         }
       }
 
 
-      String[] ids = TimeZone.getAvailableIDs((houroffset * 60 + minuteoffset) * 60 * 1000);
-      String timeZoneID = "custom";
-      if (ids.length != 0)
-        timeZoneID = ids[0];
-      SimpleTimeZone pdt = new SimpleTimeZone((houroffset * 60 + minuteoffset) * 60 * 1000, timeZoneID);
 
-      Calendar calendar = new GregorianCalendar(pdt);
+      String timeZoneID = "GMT";
+      if (negativeOffset)
+        timeZoneID = timeZoneID+"-";
+      timeZoneID = timeZoneID + StringRoutines.padStringLeft(Integer.toString(houroffset), 2, '0') +
+                                StringRoutines.padStringLeft(Integer.toString(minuteoffset), 2, '0');
+
+
+      TimeZone zone = TimeZone.getTimeZone(timeZoneID);
+
+      Calendar calendar = new GregorianCalendar(zone);
       calendar.set(year, month-1, day, hour, minute, second);
       calendar.set(Calendar.MILLISECOND, millisecond);
 
index c641a58..96f2558 100755 (executable)
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  * In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with  any library licensed under the Apache Software License, 
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library 
- * (or with modified versions of the above that use the same license as the above), 
- * and distribute linked combinations including the two.  You must obey the 
- * GNU General Public License in all respects for all of the code used other than 
- * the above mentioned libraries.  If you modify this file, you may extend this 
- * exception to your version of the file, but you are not obligated to do so.  
+ * the code of this program with  any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two.  You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries.  If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
  * If you do not wish to do so, delete this exception statement from your version.
  */
 package mir.util;
@@ -208,4 +208,29 @@ public class StringRoutines {
 
     return result;
   }
+
+  public static String replicateString(String aString, int aCount) {
+    StringBuffer result = new StringBuffer();
+
+    for (int i=0; i<aCount; i++)
+      result.append(aString);
+
+    return result.toString();
+  }
+
+  public static String replicateChar(char aCharacter, int aCount) {
+    char result[] = new char[aCount];
+
+    for (int i=0; i<aCount; i++)
+      result[i]= aCharacter;
+
+    return new String(result);
+  }
+
+  public static String padStringLeft(String aString, int aLength, char aPadCharacter) {
+    if (aString.length()<aLength)
+      return replicateChar(aPadCharacter, aLength-aString.length()) + aString;
+    else
+      return aString;
+  }
 }
\ No newline at end of file