From 78d11570e4c4e2733dad81ce45457d547b655400 Mon Sep 17 00:00:00 2001 From: Danial Klimkin Date: Wed, 12 Apr 2017 23:31:53 +0200 Subject: [PATCH] Let me fix CET/CEST once again --- .../core/tests/util/DateUtilsTest.java | 16 +++++++++++----- .../danoeh/antennapod/core/util/DateUtils.java | 3 ++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/core/src/androidTest/java/de/danoeh/antennapod/core/tests/util/DateUtilsTest.java b/core/src/androidTest/java/de/danoeh/antennapod/core/tests/util/DateUtilsTest.java index bdd114f46..0b28615a7 100644 --- a/core/src/androidTest/java/de/danoeh/antennapod/core/tests/util/DateUtilsTest.java +++ b/core/src/androidTest/java/de/danoeh/antennapod/core/tests/util/DateUtilsTest.java @@ -110,10 +110,16 @@ public class DateUtilsTest extends AndroidTestCase { } public void testParseDateWithForCest() throws Exception { - GregorianCalendar exp = new GregorianCalendar(2017, 0, 28, 23, 00, 00); - exp.setTimeZone(TimeZone.getTimeZone("UTC")); - Date expected = new Date(exp.getTimeInMillis()); - Date actual = DateUtils.parse("Sun, 29 Jan 2017 00:00:00 CEST"); - assertEquals(expected, actual); + GregorianCalendar exp1 = new GregorianCalendar(2017, 0, 28, 22, 00, 00); + exp1.setTimeZone(TimeZone.getTimeZone("UTC")); + Date expected1 = new Date(exp1.getTimeInMillis()); + Date actual1 = DateUtils.parse("Sun, 29 Jan 2017 00:00:00 CEST"); + assertEquals(expected1, actual1); + + GregorianCalendar exp2 = new GregorianCalendar(2017, 0, 28, 23, 00, 00); + exp2.setTimeZone(TimeZone.getTimeZone("UTC")); + Date expected2 = new Date(exp2.getTimeInMillis()); + Date actual2 = DateUtils.parse("Sun, 29 Jan 2017 00:00:00 CET"); + assertEquals(expected2, actual2); } } diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/DateUtils.java b/core/src/main/java/de/danoeh/antennapod/core/util/DateUtils.java index c06921c95..f118d4e53 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/DateUtils.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/DateUtils.java @@ -28,7 +28,8 @@ public class DateUtils { String date = input.trim().replace('/', '-').replaceAll("( ){2,}+", " "); // CEST is widely used but not in the "ISO 8601 Time zone" list. Let's hack around. - date = date.replaceAll("CEST$", "+01:00"); + date = date.replaceAll("CEST$", "+02:00"); + date = date.replaceAll("CET$", "+01:00"); // if datetime is more precise than seconds, make sure the value is in ms if (date.contains(".")) {