DisplayFormat { public static String shortTimeSince(final long refTime) { long deltaTimeMs = WearUtil.msSince(refTime); if (deltaTimeMs < Constants.MINUTE_IN_MS) { return "0'"; } else if (deltaTimeMs < Constants.HOUR_IN_MS) { int minutes = (int) (deltaTimeMs / Constants.MINUTE_IN_MS); return minutes + "'"; } else if (deltaTimeMs < Constants.DAY_IN_MS) { int hours = (int) (deltaTimeMs / Constants.HOUR_IN_MS); return hours + "h"; } else { int days = (int) (deltaTimeMs / Constants.DAY_IN_MS); if (days < 7) { return days + "d"; } else { int weeks = days / 7; return weeks + "w"; } } }  static String deltaSymbol(); static String verticalSeparatorSymbol(); static String basalRateSymbol(); static String shortTimeSince(final long refTime); static String shortTrend(final RawDisplayData raw); static String longGlucoseLine(final RawDisplayData raw); static String longDetailsLine(final RawDisplayData raw); static Pair<String, String> detailedIob(RawDisplayData raw); static Pair<String, String> detailedCob(final RawDisplayData raw); static final int MAX_FIELD_LEN_LONG; static final int MAX_FIELD_LEN_SHORT; static final int MIN_FIELD_LEN_COB; static final int MIN_FIELD_LEN_IOB; }
@Test public void shortTimeSinceTest() { assertThat(DisplayFormat.shortTimeSince(backInTime(0,0,0,0)), is("0'")); assertThat(DisplayFormat.shortTimeSince(backInTime(0,0,0,5)), is("0'")); assertThat(DisplayFormat.shortTimeSince(backInTime(0,0,0,55)), is("0'")); assertThat(DisplayFormat.shortTimeSince(backInTime(0,0,1,0)), is("1'")); assertThat(DisplayFormat.shortTimeSince(backInTime(0,0,1,59)), is("1'")); assertThat(DisplayFormat.shortTimeSince(backInTime(0,0,2,0)), is("2'")); assertThat(DisplayFormat.shortTimeSince(backInTime(0,0,3,0)), is("3'")); assertThat(DisplayFormat.shortTimeSince(backInTime(0,0,4,0)), is("4'")); assertThat(DisplayFormat.shortTimeSince(backInTime(0,0,10,0)), is("10'")); assertThat(DisplayFormat.shortTimeSince(backInTime(0,0,30,0)), is("30'")); assertThat(DisplayFormat.shortTimeSince(backInTime(0,0,59,0)), is("59'")); assertThat(DisplayFormat.shortTimeSince(backInTime(0,0,59,59)), is("59'")); assertThat(DisplayFormat.shortTimeSince(backInTime(0,1,0,0)), is("1h")); assertThat(DisplayFormat.shortTimeSince(backInTime(0,1,30,0)), is("1h")); assertThat(DisplayFormat.shortTimeSince(backInTime(0,1,59,59)), is("1h")); assertThat(DisplayFormat.shortTimeSince(backInTime(0,2,0,0)), is("2h")); assertThat(DisplayFormat.shortTimeSince(backInTime(0,3,0,0)), is("3h")); assertThat(DisplayFormat.shortTimeSince(backInTime(0,4,0,0)), is("4h")); assertThat(DisplayFormat.shortTimeSince(backInTime(0,5,0,0)), is("5h")); assertThat(DisplayFormat.shortTimeSince(backInTime(0,12,0,0)), is("12h")); assertThat(DisplayFormat.shortTimeSince(backInTime(0,18,0,0)), is("18h")); assertThat(DisplayFormat.shortTimeSince(backInTime(0,23,59,59)), is("23h")); assertThat(DisplayFormat.shortTimeSince(backInTime(1,0,0,0)), is("1d")); assertThat(DisplayFormat.shortTimeSince(backInTime(1,12,0,0)), is("1d")); assertThat(DisplayFormat.shortTimeSince(backInTime(1,23,59,59)), is("1d")); assertThat(DisplayFormat.shortTimeSince(backInTime(2,0,0,0)), is("2d")); assertThat(DisplayFormat.shortTimeSince(backInTime(3,0,0,0)), is("3d")); assertThat(DisplayFormat.shortTimeSince(backInTime(4,0,0,0)), is("4d")); assertThat(DisplayFormat.shortTimeSince(backInTime(5,0,0,0)), is("5d")); assertThat(DisplayFormat.shortTimeSince(backInTime(6,0,0,0)), is("6d")); assertThat(DisplayFormat.shortTimeSince(backInTime(6,23,59,59)), is("6d")); assertThat(DisplayFormat.shortTimeSince(backInTime(7,0,0,0)), is("1w")); assertThat(DisplayFormat.shortTimeSince(backInTime(8,0,0,0)), is("1w")); assertThat(DisplayFormat.shortTimeSince(backInTime(9,0,0,0)), is("1w")); assertThat(DisplayFormat.shortTimeSince(backInTime(13,23,59,59)), is("1w")); assertThat(DisplayFormat.shortTimeSince(backInTime(14,0,0,0)), is("2w")); assertThat(DisplayFormat.shortTimeSince(backInTime(21,0,0,0)), is("3w")); assertThat(DisplayFormat.shortTimeSince(backInTime(28,0,0,0)), is("4w")); assertThat(DisplayFormat.shortTimeSince(backInTime(31,0,0,0)), is("4w")); assertThat(DisplayFormat.shortTimeSince(backInTime(32,0,0,0)), is("4w")); assertThat(DisplayFormat.shortTimeSince(backInTime(35,0,0,0)), is("5w")); assertThat(DisplayFormat.shortTimeSince(backInTime(100,0,0,0)), is("14w")); assertThat(DisplayFormat.shortTimeSince(backInTime(200,0,0,0)), is("28w")); assertThat(DisplayFormat.shortTimeSince(backInTime(365,0,0,0)), is("52w")); assertThat(DisplayFormat.shortTimeSince(backInTime(366,0,0,0)), is("52w")); assertThat(DisplayFormat.shortTimeSince(backInTime(367,0,0,0)), is("52w")); }