diff --git a/source/net/filebot/format/MediaBindingBean.java b/source/net/filebot/format/MediaBindingBean.java index 22737755..0f334106 100644 --- a/source/net/filebot/format/MediaBindingBean.java +++ b/source/net/filebot/format/MediaBindingBean.java @@ -22,9 +22,10 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.math.BigDecimal; import java.math.RoundingMode; -import java.time.LocalDate; +import java.time.LocalDateTime; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -35,7 +36,6 @@ import java.util.Objects; import java.util.Optional; import java.util.SortedSet; import java.util.TreeSet; -import java.util.concurrent.TimeUnit; import java.util.regex.Pattern; import com.cedarsoftware.util.io.JsonWriter; @@ -201,10 +201,10 @@ public class MediaBindingBean { } @Define("age") - public Number getAgeInDays() { + public Long getAgeInDays() { SimpleDate releaseDate = getReleaseDate(); if (releaseDate != null) { - long days = TimeUnit.MILLISECONDS.toDays(System.currentTimeMillis() - releaseDate.getTimeStamp()); + long days = ChronoUnit.DAYS.between(releaseDate.toLocalDate(), LocalDateTime.now()); if (days >= 0) { return days; } @@ -910,7 +910,7 @@ public class MediaBindingBean { @Define("today") public SimpleDate getToday() { - return new SimpleDate(LocalDate.now()); + return new SimpleDate(LocalDateTime.now()); } @Define("home") diff --git a/source/net/filebot/similarity/EpisodeMetrics.java b/source/net/filebot/similarity/EpisodeMetrics.java index 990b2e57..0510a494 100644 --- a/source/net/filebot/similarity/EpisodeMetrics.java +++ b/source/net/filebot/similarity/EpisodeMetrics.java @@ -517,17 +517,14 @@ public enum EpisodeMetrics implements SimilarityMetric { @Override public long getTimeStamp(Object object) { if (object instanceof Episode) { - try { - long ts = ((Episode) object).getAirdate().getTimeStamp(); + SimpleDate date = ((Episode) object).getAirdate(); + + // some episodes may not have a defined airdate + if (date != null) { + long ts = date.getTimeStamp(); // big penalty for episodes not yet aired - if (ts > System.currentTimeMillis()) { - return -1; - } - - return ts; - } catch (RuntimeException e) { - return -1; // some episodes may not have airdate defined + return ts > System.currentTimeMillis() ? -1 : ts; } }