diff --git a/res/de/jClipCorn/gui/localization/locale.properties b/res/de/jClipCorn/gui/localization/locale.properties index 346a3586..ceb3d347 100644 --- a/res/de/jClipCorn/gui/localization/locale.properties +++ b/res/de/jClipCorn/gui/localization/locale.properties @@ -159,6 +159,7 @@ CCDate.Month7 = Juli CCDate.Month8 = August CCDate.Month9 = September CCDate.STRINGREP_EXTENDED = dddd, den dd.MMMM yyyy +CCDate.STRINGREP_UNSPEC = Unbekannter Zeitpunkt CCLog.Error = Error CCLog.Errors = Errors @@ -328,6 +329,7 @@ CheckDatabaseDialog.Error.ERR_33 = Die Gesehen-Historie e CheckDatabaseDialog.Error.ERR_34 = Die Gruppenliste enth\u00E4lt ung\u00FCltige Gruppen CheckDatabaseDialog.Error.ERR_35 = Die interne Gruppenauflisting der Datenbank enth\u00E4lt Fehler CheckDatabaseDialog.Error.ERR_36 = Zwei Elemente verweisen auf die gleiche Online Resource +CheckDatabaseDialog.Error.ERR_37 = Der Status ist Gesehen aber es existiert keine History CheckDatabaseDialog.Errornames.ERR_01 = L\u00FCcke in Genres CheckDatabaseDialog.Errornames.ERR_02 = Ung\u00FCltiges Genre CheckDatabaseDialog.Errornames.ERR_03 = Falsche Dateigr\u00F6\u00DFe @@ -363,6 +365,7 @@ CheckDatabaseDialog.Errornames.ERR_33 = Invalide Historie CheckDatabaseDialog.Errornames.ERR_34 = Fehlergafte Gruppenliste CheckDatabaseDialog.Errornames.ERR_35 = Invalide Gruppe CheckDatabaseDialog.Errornames.ERR_36 = Doppelte Online-ID +CheckDatabaseDialog.Errornames.ERR_37 = Gesehen aber keine Historie CheckDatabaseDialog.btnAutofix.text = Try to auto. fix problems CheckDatabaseDialog.btnFixSelected.text = Fix Selected CheckDatabaseDialog.btnValidate.text = Validate Database diff --git a/res/de/jClipCorn/gui/localization/locale_de_DE.properties b/res/de/jClipCorn/gui/localization/locale_de_DE.properties index a38cf71b..9344887c 100644 --- a/res/de/jClipCorn/gui/localization/locale_de_DE.properties +++ b/res/de/jClipCorn/gui/localization/locale_de_DE.properties @@ -159,6 +159,7 @@ CCDate.Month7 = Juli CCDate.Month8 = August CCDate.Month9 = September CCDate.STRINGREP_EXTENDED = dddd, den dd.MMMM yyyy +CCDate.STRINGREP_UNSPEC = Unbekannter Zeitpunkt CCLog.Error = Fehler CCLog.Errors = Fehler @@ -328,6 +329,7 @@ CheckDatabaseDialog.Error.ERR_33 = Die Gesehen-Historie e CheckDatabaseDialog.Error.ERR_34 = Die Gruppenliste enth\u00E4lt ung\u00FCltige Gruppen CheckDatabaseDialog.Error.ERR_35 = Die interne Gruppenauflisting der Datenbank enth\u00E4lt Fehler CheckDatabaseDialog.Error.ERR_36 = Zwei Elemente verweisen auf die gleiche Online Resource +CheckDatabaseDialog.Error.ERR_37 = Der Status ist Gesehen aber es existiert keine History CheckDatabaseDialog.Errornames.ERR_01 = L\u00FCcke in Genres CheckDatabaseDialog.Errornames.ERR_02 = Ung\u00FCltiges Genre CheckDatabaseDialog.Errornames.ERR_03 = Falsche Dateigr\u00F6\u00DFe @@ -363,6 +365,7 @@ CheckDatabaseDialog.Errornames.ERR_33 = Invalide Historie CheckDatabaseDialog.Errornames.ERR_34 = Fehlergafte Gruppenliste CheckDatabaseDialog.Errornames.ERR_35 = Invalide Gruppe CheckDatabaseDialog.Errornames.ERR_36 = Doppelte Online-ID +CheckDatabaseDialog.Errornames.ERR_37 = Gesehen aber keine Historie CheckDatabaseDialog.btnAutofix.text = Versuche Probleme autom. zu l\u00F6sen CheckDatabaseDialog.btnFixSelected.text = Markiertes Problem l\u00F6sen CheckDatabaseDialog.btnValidate.text = \u00DCberpr\u00FCfe Datenbank diff --git a/res/de/jClipCorn/gui/localization/locale_dl_DL.properties b/res/de/jClipCorn/gui/localization/locale_dl_DL.properties index b92bfd8c..18f2b8c9 100644 --- a/res/de/jClipCorn/gui/localization/locale_dl_DL.properties +++ b/res/de/jClipCorn/gui/localization/locale_dl_DL.properties @@ -159,6 +159,7 @@ CCDate.Month7 = Juli CCDate.Month8 = August CCDate.Month9 = September CCDate.STRINGREP_EXTENDED = dddd, den dd.MMMM yyyy +CCDate.STRINGREP_UNSPEC = Unbekannter Zeitpunkt CCLog.Error = Error CCLog.Errors = Errors @@ -328,6 +329,7 @@ CheckDatabaseDialog.Error.ERR_33 = Die Gesehen-Historie e CheckDatabaseDialog.Error.ERR_34 = Die Gruppenliste enth\u00E4lt ung\u00FCltige Gruppen CheckDatabaseDialog.Error.ERR_35 = Die interne Gruppenauflisting der Datenbank enth\u00E4lt Fehler CheckDatabaseDialog.Error.ERR_36 = Zwei Elemente verweisen auf die gleiche Online Resource +CheckDatabaseDialog.Error.ERR_37 = Der Status ist Gesehen aber es existiert keine History CheckDatabaseDialog.Errornames.ERR_01 = L\u00FCcke in Genres CheckDatabaseDialog.Errornames.ERR_02 = Ung\u00FCltiges Genre CheckDatabaseDialog.Errornames.ERR_03 = Falsche Dateigr\u00F6\u00DFe @@ -363,6 +365,7 @@ CheckDatabaseDialog.Errornames.ERR_33 = Invalide Historie CheckDatabaseDialog.Errornames.ERR_34 = Fehlergafte Gruppenliste CheckDatabaseDialog.Errornames.ERR_35 = Invalide Gruppe CheckDatabaseDialog.Errornames.ERR_36 = Doppelte Online-ID +CheckDatabaseDialog.Errornames.ERR_37 = Gesehen aber keine Historie CheckDatabaseDialog.btnAutofix.text = Try to auto. fix problems CheckDatabaseDialog.btnFixSelected.text = Fix Selected CheckDatabaseDialog.btnValidate.text = Validate Database diff --git a/res/de/jClipCorn/gui/localization/locale_en_US.properties b/res/de/jClipCorn/gui/localization/locale_en_US.properties index 2fc30196..496ad6c3 100644 --- a/res/de/jClipCorn/gui/localization/locale_en_US.properties +++ b/res/de/jClipCorn/gui/localization/locale_en_US.properties @@ -159,6 +159,7 @@ CCDate.Month7 = July CCDate.Month8 = August CCDate.Month9 = September CCDate.STRINGREP_EXTENDED = dddd, the dd.MMMM yyyy +CCDate.STRINGREP_UNSPEC = Unknown Datetime CCLog.Error = Error CCLog.Errors = Errors @@ -328,6 +329,7 @@ CheckDatabaseDialog.Error.ERR_33 = The viewed-history con CheckDatabaseDialog.Error.ERR_34 = The groulist contains invalid groups CheckDatabaseDialog.Error.ERR_35 = The internal group datastructure of this database contains inconsistencies CheckDatabaseDialog.Error.ERR_36 = Two different elements point to the same online ID +CheckDatabaseDialog.Error.ERR_37 = The element is viewed but the viewed-history is empty CheckDatabaseDialog.Errornames.ERR_01 = Gap in Genres CheckDatabaseDialog.Errornames.ERR_02 = Wrong Genre-ID CheckDatabaseDialog.Errornames.ERR_03 = Incorrect File Size @@ -363,6 +365,7 @@ CheckDatabaseDialog.Errornames.ERR_33 = Invalid history CheckDatabaseDialog.Errornames.ERR_34 = Invalid grouplist CheckDatabaseDialog.Errornames.ERR_35 = Invalid group CheckDatabaseDialog.Errornames.ERR_36 = Duplicate Online-ID +CheckDatabaseDialog.Errornames.ERR_37 = Viewed but empty history CheckDatabaseDialog.btnAutofix.text = Try to auto. fix problems CheckDatabaseDialog.btnFixSelected.text = Fix Selected CheckDatabaseDialog.btnValidate.text = Validate Database diff --git a/src/main/de/jClipCorn/database/databaseElement/columnTypes/CCDateTimeList.java b/src/main/de/jClipCorn/database/databaseElement/columnTypes/CCDateTimeList.java index f429b03a..8c2ab929 100644 --- a/src/main/de/jClipCorn/database/databaseElement/columnTypes/CCDateTimeList.java +++ b/src/main/de/jClipCorn/database/databaseElement/columnTypes/CCDateTimeList.java @@ -43,6 +43,12 @@ public CCDateTimeList(CCDateTime datetime) { public boolean isEmpty() { return list.isEmpty(); } + + public boolean isEmptyOrOnlyUnspecified() { + for (CCDateTime dt : list) if (! dt.isUnspecifiedDateTime()) return false; + + return true; + } public boolean any() { return !list.isEmpty(); @@ -94,25 +100,43 @@ public static CCDateTimeList create(CCDate date) { } public CCDateTime getFirstOrInvalid() { - return isEmpty() ? CCDateTime.getMinimumDateTime() : list.get(0); + List specList = getSpecifiedList(); + + if (specList.isEmpty()) return CCDateTime.getMinimumDateTime(); + + return specList.get(0); } public CCDateTime getLastOrInvalid() { - return isEmpty() ? CCDateTime.getMinimumDateTime() : list.get(count() - 1); + List specList = getSpecifiedList(); + + if (specList.isEmpty()) return CCDateTime.getMinimumDateTime(); + + return specList.get(specList.size() - 1); } public CCDate getLastDateOrInvalid() { - return isEmpty() ? CCDate.getMinimumDate() : list.get(count() - 1).date; + List specList = getSpecifiedDateList(); + + if (specList.isEmpty()) return CCDate.getMinimumDate(); + + return specList.get(specList.size() - 1); } public CCDate getFirstDateOrInvalid() { - return isEmpty() ? CCDate.getMinimumDate() : list.get(0).date; + List specList = getSpecifiedDateList(); + + if (specList.isEmpty()) return CCDate.getMinimumDate(); + + return specList.get(0); } public CCDate getAverageDateOrInvalid() { - if (isEmpty()) return CCDate.getMinimumDate(); + List specList = getSpecifiedDateList(); + + if (specList.isEmpty()) return CCDate.getMinimumDate(); - return CCDate.getAverageDate(getDateList()); + return CCDate.getAverageDate(specList); } public boolean contains(CCDateTime time) { @@ -152,13 +176,33 @@ public List getDateList() { } return l; } + + /* + * List of dates + * (dates can be not unique (cause of different times) + */ + public List getSpecifiedDateList() { + List l = new ArrayList<>(); + for (CCDateTime dt : list) { + if (! dt.isUnspecifiedDateTime()) l.add(dt.date); + } + return l; + } + + public List getSpecifiedList() { + List l = new ArrayList<>(); + for (CCDateTime dt : list) { + if (! dt.isUnspecifiedDateTime()) l.add(dt); + } + return l; + } public String getHTMLListFormatted() { return getHTMLListFormatted(0); } public String getHTMLListFormatted(int hiddenHack) { - if (isEmpty()) return ""; + if (isEmptyOrOnlyUnspecified()) return ""; StringBuilder b = new StringBuilder(); diff --git a/src/main/de/jClipCorn/database/databaseErrors/DatabaseErrorType.java b/src/main/de/jClipCorn/database/databaseErrors/DatabaseErrorType.java index d08ae34d..bf1d358e 100644 --- a/src/main/de/jClipCorn/database/databaseErrors/DatabaseErrorType.java +++ b/src/main/de/jClipCorn/database/databaseErrors/DatabaseErrorType.java @@ -39,14 +39,15 @@ public class DatabaseErrorType { public static DatabaseErrorType ERROR_INVALID_GROUPLIST = new DatabaseErrorType(34); public static DatabaseErrorType ERROR_INVALID_GROUP = new DatabaseErrorType(35); public static DatabaseErrorType ERROR_DUPLICATE_REF = new DatabaseErrorType(36); - + public static DatabaseErrorType ERROR_VIEWED_BUT_NO_HISTORY = new DatabaseErrorType(37); + private final int type; private int count = 0; - + public DatabaseErrorType(int ptype) { this.type = ptype; } - + public DatabaseErrorType(DatabaseErrorType ptype) { this.type = ptype.getType(); this.count = ptype.count; @@ -55,24 +56,24 @@ public DatabaseErrorType(DatabaseErrorType ptype) { public int getType() { return type; } - + @Override public boolean equals(Object e) { - return e instanceof DatabaseErrorType && ((DatabaseErrorType)e).getType() == this.getType(); + return e instanceof DatabaseErrorType && ((DatabaseErrorType) e).getType() == this.getType(); } @Override public int hashCode() { return type; } - + @SuppressWarnings("nls") @Override public String toString() { if (count == 0) { - return LocaleBundle.getString(String.format("CheckDatabaseDialog.Errornames.ERR_%02d", type)); + return LocaleBundle.getString(String.format("CheckDatabaseDialog.Errornames.ERR_%02d", type)); } else { - return LocaleBundle.getString(String.format("CheckDatabaseDialog.Errornames.ERR_%02d", type)) + " (" + count + ")"; + return LocaleBundle.getString(String.format("CheckDatabaseDialog.Errornames.ERR_%02d", type)) + " (" + count + ")"; } } @@ -100,28 +101,28 @@ public boolean isAutoFixable() { } else if (equals(ERROR_INVALID_CHARS_IN_PATH)) { return true; } - + return false; } - + public void incCount() { count++; } - + public void setCount(int c) { count = c; } - + public int getCount() { return count; } - + public DatabaseErrorType copy(int pcount) { DatabaseErrorType det = new DatabaseErrorType(this); det.setCount(pcount); return det; } - + public DatabaseErrorType copy() { return new DatabaseErrorType(this); } diff --git a/src/main/de/jClipCorn/database/databaseErrors/DatabaseValidator.java b/src/main/de/jClipCorn/database/databaseErrors/DatabaseValidator.java index 742059e5..6f5ef81b 100644 --- a/src/main/de/jClipCorn/database/databaseErrors/DatabaseValidator.java +++ b/src/main/de/jClipCorn/database/databaseErrors/DatabaseValidator.java @@ -590,6 +590,14 @@ private static void validateEpisode(List e, CCEpisode episode) { if (!episode.isViewed() && !episode.getViewedHistory().isEmpty()) { e.add(DatabaseError.createSingle(DatabaseErrorType.ERROR_HISTORY_BUT_UNVIEWED, episode)); } + + // ############################################### + // Viewed but no history + // ############################################### + + if (episode.isViewed() && episode.getViewedHistory().isEmpty()) { + e.add(DatabaseError.createSingle(DatabaseErrorType.ERROR_VIEWED_BUT_NO_HISTORY, episode)); + } // ############################################### // History is invalid diff --git a/src/main/de/jClipCorn/gui/guiComponents/dateTimeListEditor/DateTimeListEditor.java b/src/main/de/jClipCorn/gui/guiComponents/dateTimeListEditor/DateTimeListEditor.java index 6e4f4a53..9760076c 100644 --- a/src/main/de/jClipCorn/gui/guiComponents/dateTimeListEditor/DateTimeListEditor.java +++ b/src/main/de/jClipCorn/gui/guiComponents/dateTimeListEditor/DateTimeListEditor.java @@ -145,7 +145,10 @@ public void actionPerformed(ActionEvent e) { @Override public void valueChanged(ListSelectionEvent e) { if (list.getSelectedIndex() >= 0) { - edAddDateTime.setValue(list.getSelectedValue()); + if (list.getSelectedValue().isUnspecifiedDateTime()) + edAddDateTime.setValue(CCDateTime.getCurrentDateTime()); + else + edAddDateTime.setValue(list.getSelectedValue()); } } }); diff --git a/src/main/de/jClipCorn/gui/guiComponents/jCCDateTimeSpinner/CCDateTimeEditor.java b/src/main/de/jClipCorn/gui/guiComponents/jCCDateTimeSpinner/CCDateTimeEditor.java index d99bac71..064df309 100644 --- a/src/main/de/jClipCorn/gui/guiComponents/jCCDateTimeSpinner/CCDateTimeEditor.java +++ b/src/main/de/jClipCorn/gui/guiComponents/jCCDateTimeSpinner/CCDateTimeEditor.java @@ -11,6 +11,7 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import de.jClipCorn.gui.localization.LocaleBundle; import de.jClipCorn.gui.log.CCLog; import de.jClipCorn.util.datetime.CCDateTime; import de.jClipCorn.util.exceptions.CCFormatException; @@ -62,7 +63,9 @@ public void commitEdit() { String text = tf.getText(); try { - if (CCDateTime.testparse(text, CCDateTime.STRINGREP_SIMPLE)) { + if (text.equalsIgnoreCase(CCDateTime.UNSPECIFIED_REPRESENTATION) || text.equalsIgnoreCase(LocaleBundle.getString("CCDate.STRINGREP_UNSPEC"))) { //$NON-NLS-1$ + owner.getModel().setValue(CCDateTime.getUnspecified()); + } else if (CCDateTime.testparse(text, CCDateTime.STRINGREP_SIMPLE)) { owner.getModel().setValue(CCDateTime.parse(text, CCDateTime.STRINGREP_SIMPLE)); } else if (CCDateTime.testparse(text, CCDateTime.STRINGREP_SIMPLESHORT)) { owner.getModel().setValue(CCDateTime.parse(text, CCDateTime.STRINGREP_SIMPLESHORT)); diff --git a/src/main/de/jClipCorn/gui/guiComponents/tableRenderer/TableDateListRenderer.java b/src/main/de/jClipCorn/gui/guiComponents/tableRenderer/TableDateListRenderer.java index 13cb0b3d..905ba310 100644 --- a/src/main/de/jClipCorn/gui/guiComponents/tableRenderer/TableDateListRenderer.java +++ b/src/main/de/jClipCorn/gui/guiComponents/tableRenderer/TableDateListRenderer.java @@ -13,7 +13,7 @@ public TableDateListRenderer() { @Override public void setValue(Object value) { CCDateTimeList d = ((CCDateTimeList)value); - if (d.isEmpty()) { + if (d.isEmptyOrOnlyUnspecified()) { setText(" - "); //$NON-NLS-1$ } else { switch (CCProperties.getInstance().PROP_SERIES_DISPLAYED_DATE.getValue()) { diff --git a/src/main/de/jClipCorn/util/datetime/CCDate.java b/src/main/de/jClipCorn/util/datetime/CCDate.java index 5d242f91..eb62c05f 100644 --- a/src/main/de/jClipCorn/util/datetime/CCDate.java +++ b/src/main/de/jClipCorn/util/datetime/CCDate.java @@ -33,6 +33,7 @@ public final class CCDate implements Comparable, StringSpecSupplier { private static final CCDate DATE_MIN = new CCDate(1, 1, YEAR_MIN); private static final CCDate DATE_MAX = new CCDate(31, 12, YEAR_MAX); public static final String MIN_SQL = DATE_MIN.getSQLStringRepresentation(); + private static final CCDate UNSPECIFIED = new CCDate(99, 99, 99); private static HashSet stringSpecifier = null; // { 'y', 'M', 'd' } @@ -120,6 +121,10 @@ public static CCDate getMaximumDate() { //Not really Maximum - just extreme high return DATE_MAX; } + public static CCDate getUnspecified() { + return UNSPECIFIED; + } + public String getMonthName() { return MONTHNAMES[month]; } @@ -423,7 +428,7 @@ public int getDayDifferenceTo(CCDate other) { @Override public String toString() { - return getSimpleStringRepresentation(); + return ":" + getSQLStringRepresentation(); //$NON-NLS-1$ } public int compare(CCDate other) { @@ -509,6 +514,10 @@ public static int compare(CCDate o1, CCDate o2) { public boolean isMinimum() { return 1 == getDay() && 1 == getMonth() && YEAR_MIN == getYear(); } + + public boolean isUnspecifiedDate() { + return 99 == getDay() && 99 == getMonth() && 99 == getYear(); + } public static CCDate getMinDate(List datelist) { CCDate min = getMaximumDate(); @@ -563,6 +572,8 @@ public long asMilliseconds() { /// This checks _not_ for unset dates (1.1.1900) /// This checks only for really invalid dates (eg 40.13.1800) public boolean isValidDate() { + if (isUnspecifiedDate()) return true; + if (! (year >= YEAR_MIN)) { return false; } diff --git a/src/main/de/jClipCorn/util/datetime/CCDateTime.java b/src/main/de/jClipCorn/util/datetime/CCDateTime.java index 4468d68c..8aaf9a10 100644 --- a/src/main/de/jClipCorn/util/datetime/CCDateTime.java +++ b/src/main/de/jClipCorn/util/datetime/CCDateTime.java @@ -5,6 +5,7 @@ import java.util.Map; import java.util.Map.Entry; +import de.jClipCorn.gui.localization.LocaleBundle; import de.jClipCorn.util.exceptions.CCFormatException; import de.jClipCorn.util.exceptions.DateTimeFormatException; import de.jClipCorn.util.parser.StringSpecParser; @@ -14,6 +15,8 @@ public class CCDateTime implements Comparable, StringSpecSupplier { public static CCDateTime STATIC_SUPPLIER = CCDateTime.create(CCDate.create(1, 1, 2000), CCTime.getUnspecified()); + public final static String UNSPECIFIED_REPRESENTATION = "UNSPECIFIED"; + public final static String STRINGREP_SIMPLE = "dd.MM.yyyy HH:mm:ss"; //$NON-NLS-1$ public final static String STRINGREP_SIMPLESHORT = "dd.MM.yyyy HH:mm"; //$NON-NLS-1$ public final static String STRINGREP_SIMPLEDATE = "dd.MM.yyyy"; //$NON-NLS-1$ @@ -44,6 +47,8 @@ public static CCDateTime createFromSQL(String str) throws CCFormatException { return new CCDateTime(CCDate.createFromSQL(parts[0]), CCTime.createFromSQL(parts[1])); } else if (str.length() == 10) { return new CCDateTime(CCDate.createFromSQL(str), CCTime.getUnspecified()); + } else if (str.length() == UNSPECIFIED_REPRESENTATION.length() && str.equals(UNSPECIFIED_REPRESENTATION)) { + return new CCDateTime(CCDate.getUnspecified(), CCTime.getUnspecified()); } throw new DateTimeFormatException(str); @@ -62,7 +67,9 @@ public static CCDateTime getCurrentDateTime() { } public String getSQLStringRepresentation() { - if (time.isUnspecifiedTime()) + if (isUnspecifiedDateTime()) + return UNSPECIFIED_REPRESENTATION; + else if (time.isUnspecifiedTime()) return date.getSQLStringRepresentation(); else return date.getSQLStringRepresentation() + " " + time.getSQLStringRepresentation(); @@ -70,6 +77,8 @@ public String getSQLStringRepresentation() { @Override public int compareTo(CCDateTime o) { + if (isUnspecifiedDateTime()) return -1; + int c = date.compareTo(o.date); if (c != 0) return c; @@ -99,14 +108,18 @@ public String getStringRepresentation(String fmt) { } public String getSimpleStringRepresentation() { - if (time.isUnspecifiedTime()) + if (isUnspecifiedDateTime()) + return LocaleBundle.getString("CCDate.STRINGREP_UNSPEC"); + else if (time.isUnspecifiedTime()) return getStringRepresentation(STRINGREP_SIMPLEDATE); else return getStringRepresentation(STRINGREP_SIMPLE); } public String getSimpleShortStringRepresentation() { - if (time.isUnspecifiedTime()) + if (isUnspecifiedDateTime()) + return LocaleBundle.getString("CCDate.STRINGREP_UNSPEC"); + else if (time.isUnspecifiedTime()) return getStringRepresentation(STRINGREP_SIMPLESHORTDATE); else return getStringRepresentation(STRINGREP_SIMPLESHORT); @@ -125,7 +138,9 @@ public static CCDateTime parseOrDefault(String rawData, String fmt, CCDateTime d } public String getLocalStringRepresentation() { - if (time.isUnspecifiedTime()) + if (isUnspecifiedDateTime()) + return LocaleBundle.getString("CCDate.STRINGREP_UNSPEC"); + else if (time.isUnspecifiedTime()) return getStringRepresentation(STRINGREP_SIMPLEDATE); else return getStringRepresentation(STRINGREP_LOCAL); @@ -269,6 +284,7 @@ public boolean isLessThan(CCDateTime other) { } public boolean isEquals(CCDateTime other) { + if (this.isUnspecifiedDateTime() || other.isUnspecifiedDateTime()) return false; return compareTo(other) == 0; } @@ -302,12 +318,25 @@ public static CCDateTime getMinimumDateTime() { return new CCDateTime(CCDate.getMinimumDate(), CCTime.getMidnight()); } + public static CCDateTime getUnspecified() { + return new CCDateTime(CCDate.getUnspecified(), CCTime.getUnspecified()); + } + public boolean isMinimum() { return date.isMinimum() && time.isMidnight(); } + public boolean isUnspecifiedDateTime() { + return date.isUnspecifiedDate(); + } + public CCDateTime getSpecifyTimeIfNeeded(CCTime fallbacktime) { if (time.isUnspecifiedTime()) return new CCDateTime(date, fallbacktime); return this; } + + @Override + public String toString() { + return ":" + getSQLStringRepresentation(); + } } diff --git a/src/main/de/jClipCorn/util/datetime/CCTime.java b/src/main/de/jClipCorn/util/datetime/CCTime.java index a5f928ef..e42ff279 100644 --- a/src/main/de/jClipCorn/util/datetime/CCTime.java +++ b/src/main/de/jClipCorn/util/datetime/CCTime.java @@ -405,4 +405,9 @@ public boolean isValidTime() { return true; } + + @Override + public String toString() { + return ":" + getSQLStringRepresentation(); //$NON-NLS-1$ + } } \ No newline at end of file diff --git a/src/main/de/jClipCorn/util/userdataProblem/UserDataProblem.java b/src/main/de/jClipCorn/util/userdataProblem/UserDataProblem.java index 008461ac..567d13b0 100644 --- a/src/main/de/jClipCorn/util/userdataProblem/UserDataProblem.java +++ b/src/main/de/jClipCorn/util/userdataProblem/UserDataProblem.java @@ -426,7 +426,7 @@ public static void testEpisodeData(List ret, CCSeason season, C //################################################################################################################ for (CCDateTime lvdate : lvdates) { - if (lvdate.isLessThan(CCDate.getMinimumDate())) { + if (!lvdate.isUnspecifiedDateTime() && lvdate.isLessThan(CCDate.getMinimumDate())) { ret.add(new UserDataProblem(UserDataProblem.PROBLEM_DATE_TOO_LESS)); } } diff --git a/src/test/de/jClipCorn/test/TestCCDateTime.java b/src/test/de/jClipCorn/test/TestCCDateTime.java index aedf9b1f..0e3f7ce1 100644 --- a/src/test/de/jClipCorn/test/TestCCDateTime.java +++ b/src/test/de/jClipCorn/test/TestCCDateTime.java @@ -1,6 +1,7 @@ package de.jClipCorn.test; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import org.junit.Test; @@ -41,6 +42,10 @@ public void testParse() throws CCFormatException { assertEquals(CCDateTime.create(19,8,2020, 7,50,35), CCDateTime.parse("19,8,2020 07:50:35", "dd,MM,yyyy HH:mm:ss")); assertEquals(CCDateTime.create(19,8,2020, 99,99,99), CCDateTime.parse("19,8,2020", "dd,MM,yyyy")); assertTrue(CCDateTime.parse("19,8,2020", "dd,MM,yyyy").time.isUnspecifiedTime()); + + assertTrue(CCDateTime.createFromSQL("UNSPECIFIED").isUnspecifiedDateTime()); + assertTrue(CCDateTime.createFromSQL("2016-09-07").time.isUnspecifiedTime()); + assertEquals(CCDateTime.create(7,9,2016, 12,13,14), CCDateTime.createFromSQL("2016-09-07 12:13:14")); } @Test @@ -72,4 +77,16 @@ public void testOrder() { assertEquals(+1, CCDateTime.create(30,8,2020, 7,50,35).compareTo(CCDateTime.createDateOnly(19,8,2020))); } + + @Test + public void testUnspecified() { + assertEquals(+1, CCDateTime.create(19,8,2020, 7,50,35).compareTo(CCDateTime.getUnspecified())); + assertEquals(-1, CCDateTime.getUnspecified().compareTo(CCDateTime.createDateOnly(19,8,2020))); + + assertFalse(00 == CCDateTime.getUnspecified().compareTo(CCDateTime.getUnspecified())); + + assertFalse(CCDateTime.getUnspecified().isEquals(CCDateTime.getUnspecified())); + assertFalse(CCDateTime.create(19,8,2020, 7,50,35).isEquals(CCDateTime.getUnspecified())); + assertFalse(CCDateTime.getUnspecified().isEquals(CCDateTime.createDateOnly(19,8,2020))); + } }