diff --git a/CHANGELOG.md b/CHANGELOG.md index 0526ab7..b62801e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Development version +# Version 0.5.3 - 2020-08-05 + * Consider the date for event caches during comparison. # Version 0.5.2 - 2020-07-08 @@ -31,7 +33,7 @@ # Version 0.4.0 - 2020-05-22 * Add fallback methods for opening an URL in the web browser. -* View logs as plaintext instead of HTML. This should finally provide correct linebreaks in the text. +* View logs as plaintext instead of HTML. This should finally provide correct line breaks in the text. * Allow sending modified logs. * Add support for Travis CI for automated `master` builds. * Fix log type for webcam caches. @@ -84,7 +86,7 @@ # Version 0.2.43 - 2017-05-02 * Perform some refactoring. -* Store information about HTTP responses witout code 200. +* Store information about HTTP responses without code 200. * Handle OKAPI error responses for the username and cache getter. * Switch OKAPI responses to JSON. * Split OKAPI result caching and cache lookup. @@ -174,8 +176,8 @@ # Version 0.2z - 2016-02-25 -* Only enable undo menu if undo action are available. -* Allow restarting the program to update used heap size. +* Only enable undo menu if undo actions are available. +* Allow restarting the program to update the used heap size. * Add OC username to settings. # Version 0.2y - 2016-02-24 @@ -192,7 +194,7 @@ # Version 0.2w - 2016-02-21 * Move filters to main menu. -* Allow to set cache coordinates as location using a right click. +* Allow setting cache coordinates as location using a right click. * Display number of selected caches. * Switch to HTTPS. * Add undo support. @@ -228,7 +230,7 @@ * Unify found log definition. * Add cache name filter. * Ignore caches ignored on OC. -* Use multithreaded filtering. +* Use multi-threaded filtering. # Version 0.2q - 2016-01-28 @@ -240,7 +242,7 @@ # Version 0.2o - 2016-01-26 -* Bugfix for multithreading. +* Bugfix for multi-threading. * Allow reduced GPX files. # Version 0.2n - 2016-01-19 diff --git a/build.gradle b/build.gradle index 1f87ecb..692780c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,12 +1,12 @@ plugins { // Apply the versions plugin to check for module dependency updates. - id 'com.github.ben-manes.versions' version '0.28.0' + id 'com.github.ben-manes.versions' version '0.29.0' // Apply the Google Java formatter plugin for automatically reformatting files. id 'com.github.sherter.google-java-format' version '0.9' // Create runtime images. - id 'org.beryx.runtime' version '1.10.0' + id 'org.beryx.runtime' version '1.11.2' } // Apply the java plugin to add support for Java. @@ -40,7 +40,7 @@ repositories { dependencies { implementation group: 'commons-codec', name: 'commons-codec', version: '1.14' - implementation group: 'org.apache.commons', name: 'commons-text', version: '1.8' + implementation group: 'org.apache.commons', name: 'commons-text', version: '1.9' implementation group: 'com.github.scribejava', name: 'scribejava-core', version: '6.9.0' implementation group: 'org.openstreetmap.jmapviewer', name: 'jmapviewer', version: '2.14' implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.6' @@ -58,7 +58,7 @@ project.ext.ocOkapiPropertiesFile = projectDir.getPath() + "${File.separator}oc_ sourceCompatibility = 1.8 targetCompatibility = 1.8 -version = '0.5.2' +version = '0.5.3' wrapper { gradleVersion = '6.5.1' @@ -124,11 +124,13 @@ clean.doFirst { jar { archiveBaseName = 'cm' - if (project.isTravis()) version = 'ci' + if (project.isTravis()) { + archiveVersion = 'ci' + } manifest { attributes 'Main-Class': mainClassName } - duplicatesStrategy = DuplicatesStrategy.INCLUDE // allow duplicates + duplicatesStrategy = DuplicatesStrategy.INCLUDE // Allow duplicates. from { configurations.compileClasspath.collect { @@ -183,7 +185,7 @@ task jpackageImageZip(type: Zip) { description = 'Bundles the jpackage image as a ZIP file.' from "${buildDir}/jpackage/cmanager" include '**/*' - archiveName "cmanager-${version}_${project.getSystemString()}.zip" + archiveName "cmanager-${archiveVersion}_${project.getSystemString()}.zip" destinationDir file("${buildDir}/jpackage/") } jpackageImageZip.dependsOn jpackageImage diff --git a/src/main/java/cmanager/util/DateTimeUtil.java b/src/main/java/cmanager/util/DateTimeUtil.java index 034dd06..d6ed92f 100644 --- a/src/main/java/cmanager/util/DateTimeUtil.java +++ b/src/main/java/cmanager/util/DateTimeUtil.java @@ -39,6 +39,34 @@ public static boolean isTooOldWithMonths(final File file, int maximumAgeInMonths return DateTimeUtil.isTooOldWithMonths(fileModifiedDate, maximumAgeInMonths); } + /** + * Check if the given datetime is older than the given number of days. + * + * @param oldTime The datetime to check the invalidation for. + * @param maximumAgeInDays The maximum age in days allowed. + * @return Whether the given datetime is too old. + */ + public static boolean isTooOldWithDays(final LocalDateTime oldTime, int maximumAgeInDays) { + final LocalDateTime invalidationTime = oldTime.plusDays(maximumAgeInDays); + final LocalDateTime now = LocalDateTime.now(); + + return invalidationTime.isBefore(now); + } + + /** + * Check if the given file is older than the given number of days. + * + * @param file The file to check the modification time for. + * @param maximumAgeInDays The maximum age in days allowed. + * @return Whether the file is too old. + */ + public static boolean isTooOldWithDays(final File file, int maximumAgeInDays) { + final LocalDateTime fileModifiedDate = + LocalDateTime.ofInstant( + Instant.ofEpochMilli(file.lastModified()), ZoneId.systemDefault()); + return DateTimeUtil.isTooOldWithDays(fileModifiedDate, maximumAgeInDays); + } + /** * Check if the given file is too old. *