diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/DateTimeUtils.java b/app/src/main/java/gr/thmmy/mthmmy/utils/DateTimeUtils.java index 0c7a3591..659cde2f 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/DateTimeUtils.java +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/DateTimeUtils.java @@ -43,12 +43,10 @@ class DateTimeUtils { count += 1; } else if (duration < 26*DAY_IN_MILLIS) { count = duration/DAY_IN_MILLIS; - format = "%d day"; + format = "%dd"; mod = duration % DAY_IN_MILLIS; if(mod >= 12*HOUR_IN_MILLIS) count += 1; - if(count>1) - format = format + 's'; } else if (duration < 320*DAY_IN_MILLIS) { count = duration/MONTH_IN_MILLIS; format = "%d month"; diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/ThmmyDateTimeParser.java b/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/ThmmyDateTimeParser.java index 4a7f58ed..01014ec6 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/ThmmyDateTimeParser.java +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/ThmmyDateTimeParser.java @@ -20,11 +20,10 @@ import timber.log.Timber; public class ThmmyDateTimeParser { private static final DateTimeParser[] parsers = { - DateTimeFormat.forPattern("HH:mm:ss").getParser(), DateTimeFormat.forPattern("hh:mm:ss a").getParser(), - DateTimeFormat.forPattern("MMMM d, Y, HH:mm:ss").getParser(), + DateTimeFormat.forPattern("HH:mm:ss").getParser(), DateTimeFormat.forPattern("MMMM d, Y, hh:mm:ss a").getParser(), - DateTimeFormat.forPattern("d MMMM Y, HH:mm:ss").getParser(), + DateTimeFormat.forPattern("MMMM d, Y, HH:mm:ss").getParser(), DateTimeFormat.forPattern("d MMMM Y, HH:mm:ss").getParser(), DateTimeFormat.forPattern("Y-M-d, HH:mm:ss").getParser(), DateTimeFormat.forPattern("d-M-Y, HH:mm:ss").getParser() @@ -38,9 +37,12 @@ public class ThmmyDateTimeParser { private static final Locale greekLocale = new Locale("el", "GR"); private static final Locale englishLocale = new Locale("en", "US"); - private static final Pattern pattern = Pattern.compile("\\s(1[3-9]|2[0-3]:)"); + private static final Pattern pattern = Pattern.compile("\\s((1[3-9]|2[0-3]):)"); + + private ThmmyDateTimeParser(){} public static String convertToTimestamp(String thmmyDateTime){ + Timber.d("Will attempt to convert %s to timestamp.", thmmyDateTime); String originalDateTime = thmmyDateTime; DateTimeZone dtz = getDtz(); @@ -67,6 +69,7 @@ public class ThmmyDateTimeParser { DateFormatSymbols dfs = DateTimeUtils.getDateFormatSymbols(greekLocale); thmmyDateTime = thmmyDateTime.replace("am",dfs.getAmPmStrings()[0]); thmmyDateTime = thmmyDateTime.replace("pm",dfs.getAmPmStrings()[1]); + Timber.d("Attempting to parse DateTime %s using Greek Locale...", thmmyDateTime); dateTime=formatter.withZone(dtz).withLocale(greekLocale).parseDateTime(thmmyDateTime); } catch (IllegalArgumentException e2){ diff --git a/app/src/test/java/gr/thmmy/mthmmy/utils/DateTimeUtilsTest.java b/app/src/test/java/gr/thmmy/mthmmy/utils/DateTimeUtilsTest.java index 3baedd6b..eb214cb0 100644 --- a/app/src/test/java/gr/thmmy/mthmmy/utils/DateTimeUtilsTest.java +++ b/app/src/test/java/gr/thmmy/mthmmy/utils/DateTimeUtilsTest.java @@ -40,12 +40,12 @@ public class DateTimeUtilsTest { "21h", "21h", "22h", - "1 day", - "1 day", - "2 days", - "2 days", - "3 days", - "16 days", + "1d", + "1d", + "2d", + "2d", + "3d", + "16d", "1 month", "2 months", "1 year",