Author: jflesch
Date: 2007-08-13 16:25:07 +0000 (Mon, 13 Aug 2007)
New Revision: 14651
Modified:
trunk/apps/Thaw/src/thaw/plugins/miniFrost/DraftPanel.java
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKDraft.java
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessageParser.java
trunk/apps/Thaw/src/thaw/plugins/miniFrost/interfaces/Draft.java
Log:
Use GMT time instead of local time + fix a possible NPE when sending a message
Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/DraftPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/DraftPanel.java 2007-08-13
15:41:22 UTC (rev 14650)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/DraftPanel.java 2007-08-13
16:25:07 UTC (rev 14651)
@@ -22,6 +22,7 @@
import java.util.Date;
import thaw.core.I18n;
+import thaw.core.Logger;
import thaw.plugins.signatures.Identity;
@@ -167,6 +168,25 @@
return panel;
}
+
+ public static Date getGMTDate() {
+ /* dirty way to obtain the GMT date */
+
+ SimpleDateFormat gmtFormat = new SimpleDateFormat("yyyy.M.d
HH:mm:ss");
+ gmtFormat.setTimeZone(java.util.TimeZone.getTimeZone("GMT"));
+
+ String dateStr = gmtFormat.format(new Date());
+
+ SimpleDateFormat finalDate = new SimpleDateFormat("yyyy.M.d
HH:mm:ss");
+
+ try {
+ return finalDate.parse(dateStr);
+ } catch(java.text.ParseException e) {
+ Logger.warning(null, "DraftPanel : Can't get the GMT
date => will use the local time");
+ return new Date();
+ }
+ }
+
/**
* Don't do the replacements in the text.
* Don't call Draft.setDate()
@@ -232,7 +252,7 @@
/* date */
- draft.setDate(date);
+ draft.setDate(getGMTDate());
/* POST */
Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKDraft.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKDraft.java
2007-08-13 15:41:22 UTC (rev 14650)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKDraft.java
2007-08-13 16:25:07 UTC (rev 14651)
@@ -145,7 +145,7 @@
/* we start immediatly a board refresh (we will need it) */
synchronized(board) {
board.addObserver(this);
- board.refresh(1 /* until today */);
+ board.refresh(2 /* until yesterday ; just to be sure
because of the GMT conversion etc */);
KSKMessageParser generator = new KSKMessageParser(
((inReplyTo != null) ?
inReplyTo.getMsgId() :
@@ -199,6 +199,7 @@
private boolean isBoardUpToDateForToday() {
if (!board.isRefreshing()
+ || board.getCurrentlyRefreshedDate() == null
||
(KSKBoard.getMidnight(board.getCurrentlyRefreshedDate()).getTime()
< KSKBoard.getMidnight(date).getTime()) ) {
return true;
Modified:
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessageParser.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessageParser.java
2007-08-13 15:41:22 UTC (rev 14650)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessageParser.java
2007-08-13 16:25:07 UTC (rev 14651)
@@ -75,7 +75,8 @@
Identity identity) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.M.d
HH:mm:ss");
- dateFormat.setTimeZone(java.util.TimeZone.getTimeZone("GMT"));
+ // the date is already GMT-ized
+ //dateFormat.setTimeZone(java.util.TimeZone.getTimeZone("GMT"));
this.messageId = ""; /* will be generated from the SHA1 of the
content */
this.inReplyTo = inReplyTo;
@@ -305,7 +306,7 @@
- public final static String SIGNATURE_ELEMENTS_SEPARATOR = "|";
+ public final static char SIGNATURE_ELEMENTS_SEPARATOR = '|';
/**
* @param withMsgId require to check the signature
Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/interfaces/Draft.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/interfaces/Draft.java
2007-08-13 15:41:22 UTC (rev 14650)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/interfaces/Draft.java
2007-08-13 16:25:07 UTC (rev 14651)
@@ -37,7 +37,7 @@
public void setAuthor(String nick, Identity identity);
/**
- * @param date don't forget to GMT-ize it when formatting it
+ * @param date the date provided is already GMT-ized
*/
public void setDate(java.util.Date date);