Bug 12745: CVS/Entries file timestamp day field not space padded
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/CVSDateFormatter.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/CVSDateFormatter.java
index 1bc9c91..6a38b97 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/CVSDateFormatter.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/CVSDateFormatter.java
@@ -14,12 +14,18 @@
/**
* Utility class for converting timestamps used in Entry file lines. The format
- * required in the Entry file is ISO C asctime() function (Sun Apr 7 01:29:26 1996).
+ * required in the Entry file is ISO C asctime() function (Sun Apr 7 01:29:26 1996).
+ * <p>
+ * To be compatible with asctime(), the day field in the entryline format is
+ * padded with a space and not a zero. Most other CVS clients use string comparison
+ * for timestamps based on the result of the C function asctime().
+ * </p>
*/
public class CVSDateFormatter {
- private static final String ENTRYLINE_FORMAT = "E MMM d HH:mm:ss yyyy"; //$NON-NLS-1$
+ private static final String ENTRYLINE_FORMAT = "E MMM dd HH:mm:ss yyyy"; //$NON-NLS-1$
private static final String SERVER_FORMAT = "dd MMM yyyy HH:mm:ss";//$NON-NLS-1$
+ private static final int ENTRYLINE_TENS_DAY_OFFSET = 8;
private static final SimpleDateFormat serverFormat = new SimpleDateFormat(SERVER_FORMAT, Locale.US);
private static SimpleDateFormat entryLineFormat = new SimpleDateFormat(ENTRYLINE_FORMAT, Locale.US);
@@ -39,11 +45,20 @@
}
static public Date entryLineToDate(String text) throws ParseException {
+ if (text.charAt(ENTRYLINE_TENS_DAY_OFFSET) == ' ') {
+ StringBuffer buf = new StringBuffer(text);
+ buf.setCharAt(ENTRYLINE_TENS_DAY_OFFSET, '0');
+ text = buf.toString();
+ }
return entryLineFormat.parse(text);
}
static public String dateToEntryLine(Date date) {
- return entryLineFormat.format(date);
+ String passOne = entryLineFormat.format(date);
+ if (passOne.charAt(ENTRYLINE_TENS_DAY_OFFSET) != '0') return passOne;
+ StringBuffer passTwo = new StringBuffer(passOne);
+ passTwo.setCharAt(ENTRYLINE_TENS_DAY_OFFSET, ' ');
+ return passTwo.toString();
}
/*