Fix ExpireDate issue for Database V3

This commit is contained in:
J-Jamet committed 2018-03-29 17:24:32 +02:00
1 parent c8cb79726b
commit 4aff5e3a06
2 files changed
+4 -23

No files matched your search

@@ -44,11 +44,9 @@ public class PwDate implements Cloneable, Serializable {
private byte[] cDate;
public static final Date NEVER_EXPIRE = getNeverExpire();
public static final Date NEVER_EXPIRE_BUG = getNeverExpireBug();
public static final Date DEFAULT_DATE = getDefaultDate();
public static final PwDate PW_NEVER_EXPIRE = new PwDate(NEVER_EXPIRE);
public static final PwDate PW_NEVER_EXPIRE_BUG = new PwDate(NEVER_EXPIRE_BUG);
public static final PwDate DEFAULT_PWDATE = new PwDate(DEFAULT_DATE);
private static Date getDefaultDate() {
@@ -74,24 +72,6 @@ public class PwDate implements Cloneable, Serializable {
return cal.getTime();
}
/** This date was was accidentally being written
* out when an entry was supposed to be marked as
* expired. We'll use this to silently correct those
* entries.
* @return
*/
private static Date getNeverExpireBug() {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, 2999);
cal.set(Calendar.MONTH, 11);
cal.set(Calendar.DAY_OF_MONTH, 30);
cal.set(Calendar.HOUR, 23);
cal.set(Calendar.MINUTE, 59);
cal.set(Calendar.SECOND, 59);
return cal.getTime();
}
public PwDate(byte[] buf, int offset) {
cDate = new byte[DATE_SIZE];
@@ -37,7 +37,7 @@ public abstract class PwNode<Parent extends PwGroup> implements ISmallTimeLogger
protected PwDate creation = new PwDate();
protected PwDate lastMod = new PwDate();
protected PwDate lastAccess = new PwDate();
protected PwDate expireDate = new PwDate(NEVER_EXPIRE);
protected PwDate expireDate = PW_NEVER_EXPIRE;
protected void construct(Parent parent) {
this.parent = parent;
@@ -151,7 +151,8 @@ public abstract class PwNode<Parent extends PwGroup> implements ISmallTimeLogger
}
public boolean expires() {
return ! PwDate.IsSameDate(NEVER_EXPIRE, expireDate.getDate());
return expireDate.getDate().equals(NEVER_EXPIRE)
|| expireDate.getDate().after(NEVER_EXPIRE);
}
/**