From 07ea116518bd54d86dd8d894ecdf28ca8b098c17 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Tue, 27 Dec 2016 14:04:01 +0800 Subject: [PATCH] avoid time zone issues by interpreting all dates and times as UTC --- source/net/filebot/format/MediaBindingBean.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/net/filebot/format/MediaBindingBean.java b/source/net/filebot/format/MediaBindingBean.java index df363963..99b8a503 100644 --- a/source/net/filebot/format/MediaBindingBean.java +++ b/source/net/filebot/format/MediaBindingBean.java @@ -23,6 +23,7 @@ import java.io.IOException; import java.math.BigDecimal; import java.math.RoundingMode; import java.time.LocalDateTime; +import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; @@ -217,7 +218,9 @@ public class MediaBindingBean { SimpleDate releaseDate = getReleaseDate(); if (releaseDate != null) { - long days = ChronoUnit.DAYS.between(releaseDate.toLocalDate(), LocalDateTime.now()); + // avoid time zone issues by interpreting all dates and times as UTC + long days = ChronoUnit.DAYS.between(releaseDate.toLocalDate().atStartOfDay(ZoneOffset.UTC), ZonedDateTime.now(ZoneOffset.UTC)); + if (days >= 0) { return days; }