Skip to content

Commit 7479f5e

Browse files
author
Jesse Vivanco
committed
Injecting fields was broken, so just removed it. That should be up to the client to figure out. We can at least reliably return the set of time units by using Eon.getTimeUnits(...)
1 parent f271682 commit 7479f5e

File tree

2 files changed

+4
-35
lines changed

2 files changed

+4
-35
lines changed

app/src/main/java/com/tippingcanoe/eon/sample/MainActivity.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ protected void onCreate(Bundle savedInstanceState) {
3131

3232
Eon.init(builder.build());
3333

34-
Log.v("Eon", Eon.getRelativeDate("Reported {eon}, and {eon} ago.",
35-
new Date(System.currentTimeMillis() - new TimeBuilder().withYears(0).withWeeks(3).withDays(2).withHours(1).withSeconds(20).getMs()),
36-
Eon.Length.LONG,
34+
Log.v("DEBUG", "Test " + Eon.getTimeUnits(new Date(System.currentTimeMillis() - new TimeBuilder().withYears(0).withWeeks(3).withDays(2).withHours(1).withSeconds(20).getMs()),
35+
Eon.Length.MEDIUM,
36+
2,
3737
false,
3838
TimeBuilder.TimeFrames.SECOND,
39-
TimeBuilder.TimeFrames.YEAR,
39+
TimeBuilder.TimeFrames.DAY,
4040
this));
4141

4242
Log.v("Eon", Eon.getRelativeDate(new Date(System.currentTimeMillis() - new TimeBuilder().withYears(0).withWeeks(3).withDays(2).withHours(1).withSeconds(20).getMs()),

library/src/main/java/com/tippingcanoe/eon/Eon.java

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,6 @@ public static void init(CustomTimeFrames timeFrames) {
1717
customTimeFrames = timeFrames;
1818
}
1919

20-
/**
21-
* Supply your own string to be injected with time units (e.g. "Submitted {eon}, and {eon} ago"
22-
* might be converted to "Submitted 5 minutes, and 2 seconds ago").
23-
*
24-
* @param eonFormattedString
25-
* @param origin
26-
* @param length
27-
* @param includeZeroUnits
28-
* @param smallestUnit
29-
* @param largestUnit
30-
* @param context
31-
* @return
32-
*/
33-
public static String getRelativeDate(String eonFormattedString, Date origin, Length length, boolean includeZeroUnits, TimeBuilder.TimeFrames smallestUnit, TimeBuilder.TimeFrames largestUnit, Context context) {
34-
35-
final String KEY_REGEX = "\\{eon\\}";
36-
String[] placeholders = eonFormattedString.split(KEY_REGEX);
37-
38-
if (placeholders.length > 0) {
39-
40-
List<String> units = getTimeUnits(origin, length, placeholders.length, includeZeroUnits, smallestUnit, largestUnit, context);
41-
42-
// NOTE: units and placeholders should have the same length
43-
for (int i = 0; i < placeholders.length; i++) {
44-
eonFormattedString = eonFormattedString.replaceFirst(KEY_REGEX, units.get(i));
45-
}
46-
}
47-
48-
return eonFormattedString;
49-
}
50-
5120
public static List<String> getTimeUnits(Date origin, Length length, int maxUnits, boolean includeZeroUnits, TimeBuilder.TimeFrames smallestUnit, TimeBuilder.TimeFrames largestUnit, Context context) {
5221

5322
long currentMs = System.currentTimeMillis();

0 commit comments

Comments
 (0)