Browse Source

More relative time improvements & fixes

widgets
Ezerous 5 years ago
parent
commit
0322322dde
  1. 8
      app/src/main/java/gr/thmmy/mthmmy/utils/DateTimeUtils.java
  2. 6
      app/src/main/java/gr/thmmy/mthmmy/utils/parsing/ThmmyDateTimeParser.java
  3. 1
      app/src/test/java/gr/thmmy/mthmmy/utils/parsing/ThmmyDateTimeParserTest.java

8
app/src/main/java/gr/thmmy/mthmmy/utils/DateTimeUtils.java

@ -45,8 +45,12 @@ public class DateTimeUtils {
count = duration/HOUR_IN_MILLIS;
format = "%dh";
mod = (duration%HOUR_IN_MILLIS)/MINUTE_IN_MILLIS;
if(count<4 && mod>10 && mod<50)
format = format + mod +"m";
if(count<3 && mod>9 && mod<51){
if(count==0)
format = mod +"m";
else
format = format + " " + mod +"m";
}
else if(mod >= 30)
count += 1;
} else if (duration < 26*DAY_IN_MILLIS) {

6
app/src/main/java/gr/thmmy/mthmmy/utils/parsing/ThmmyDateTimeParser.java

@ -52,6 +52,7 @@ public class ThmmyDateTimeParser {
thmmyDateTime = (new DateTime()).toString("MMMM d, Y, ") + thmmyDateTime;
//Don't even ask
if(thmmyDateTime.contains("am"))
thmmyDateTime = thmmyDateTime.replaceAll("\\s00:"," 12:");
// For the stupid format 23:54:12 pm
@ -77,7 +78,10 @@ public class ThmmyDateTimeParser {
return null;
}
}
return Long.toString(dateTime.getMillis());
String timestamp = Long.toString(dateTime.getMillis());
Timber.d("DateTime %s was converted to %s, or %s", originalDateTime, timestamp, dateTime.toString());
return timestamp;
}
@VisibleForTesting

1
app/src/test/java/gr/thmmy/mthmmy/utils/parsing/ThmmyDateTimeParserTest.java

@ -69,6 +69,7 @@ public class ThmmyDateTimeParserTest {
private final String [] todayDateTimes = {
"10:10:10",
"00:58:07",
"23:23:23",
"09:09:09 am",
"09:09:09 pm"

Loading…
Cancel
Save