Skip to content

Commit 6fca012

Browse files
committed
Cleaned up API. Improved tests
1 parent f7377dc commit 6fca012

71 files changed

Lines changed: 6321 additions & 5803 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎core/src/main/java/org/ocpsoft/prettytime/PrettyTime.java‎

Lines changed: 406 additions & 192 deletions
Large diffs are not rendered by default.

‎core/src/main/java/org/ocpsoft/prettytime/TimeUnit.java‎

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,30 @@
1515
*/
1616
package org.ocpsoft.prettytime;
1717

18-
1918
/**
2019
* Defines a Unit of time (e.g. seconds, minutes, hours) and its conversion to milliseconds.
2120
*
2221
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
2322
*/
24-
public interface TimeUnit {
23+
public interface TimeUnit
24+
{
2525

2626
/**
27-
* The number of milliseconds represented by each instance of this TimeUnit.
28-
* Must be a positive number greater than zero.
27+
* The number of milliseconds represented by each instance of this TimeUnit. Must be a positive number greater than
28+
* zero.
2929
*/
3030
public long getMillisPerUnit();
3131

3232
/**
33-
* The maximum quantity of this Unit to be used as a threshold for the next
34-
* largest Unit (e.g. if one <code>Second</code> represents 1000ms, and
35-
* <code>Second</code> has a maxQuantity of 5, then if the difference
36-
* between compared timestamps is larger than 5000ms, PrettyTime will move
37-
* on to the next smallest TimeUnit for calculation; <code>Minute</code>, by
38-
* default)
33+
* The maximum quantity of this Unit to be used as a threshold for the next largest Unit (e.g. if one
34+
* <code>Second</code> represents 1000ms, and <code>Second</code> has a maxQuantity of 5, then if the difference
35+
* between compared timestamps is larger than 5000ms, PrettyTime will move on to the next smallest TimeUnit for
36+
* calculation; <code>Minute</code>, by default)
3937
* <p>
4038
* millisPerUnit * maxQuantity = maxAllowedMs
4139
* <p>
42-
* If maxQuantity is zero, it will be equal to the next highest
43-
* <code>TimeUnit.getMillisPerUnit() /
44-
* this.getMillisPerUnit()</code> or infinity if there are no greater
45-
* TimeUnits
40+
* If maxQuantity is zero, it will be equal to the next highest <code>TimeUnit.getMillisPerUnit() /
41+
* this.getMillisPerUnit()</code> or infinity if there are no greater TimeUnits
4642
*/
4743
public long getMaxQuantity();
4844
}

‎core/src/main/java/org/ocpsoft/prettytime/i18n/Resources.java‎

Lines changed: 97 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -19,103 +19,103 @@
1919

2020
public class Resources extends ListResourceBundle
2121
{
22-
private static final Object[][] OBJECTS = new Object[][] {
23-
{ "CenturyPattern", "%n %u" },
24-
{ "CenturyFuturePrefix", "" },
25-
{ "CenturyFutureSuffix", " from now" },
26-
{ "CenturyPastPrefix", "" },
27-
{ "CenturyPastSuffix", " ago" },
28-
{ "CenturySingularName", "century" },
29-
{ "CenturyPluralName", "centuries" },
30-
{ "DayPattern", "%n %u" },
31-
{ "DayFuturePrefix", "" },
32-
{ "DayFutureSuffix", " from now" },
33-
{ "DayPastPrefix", "" },
34-
{ "DayPastSuffix", " ago" },
35-
{ "DaySingularName", "day" },
36-
{ "DayPluralName", "days" },
37-
{ "DecadePattern", "%n %u" },
38-
{ "DecadeFuturePrefix", "" },
39-
{ "DecadeFutureSuffix", " from now" },
40-
{ "DecadePastPrefix", "" },
41-
{ "DecadePastSuffix", " ago" },
42-
{ "DecadeSingularName", "decade" },
43-
{ "DecadePluralName", "decades" },
44-
{ "HourPattern", "%n %u" },
45-
{ "HourFuturePrefix", "" },
46-
{ "HourFutureSuffix", " from now" },
47-
{ "HourPastPrefix", "" },
48-
{ "HourPastSuffix", " ago" },
49-
{ "HourSingularName", "hour" },
50-
{ "HourPluralName", "hours" },
51-
{ "JustNowPattern", "%u" },
52-
{ "JustNowFuturePrefix", "" },
53-
{ "JustNowFutureSuffix", "moments from now" },
54-
{ "JustNowPastPrefix", "moments ago" },
55-
{ "JustNowPastSuffix", "" },
56-
{ "JustNowSingularName", "" },
57-
{ "JustNowPluralName", "" },
58-
{ "MillenniumPattern", "%n %u" },
59-
{ "MillenniumFuturePrefix", "" },
60-
{ "MillenniumFutureSuffix", " from now" },
61-
{ "MillenniumPastPrefix", "" },
62-
{ "MillenniumPastSuffix", " ago" },
63-
{ "MillenniumSingularName", "millennium" },
64-
{ "MillenniumPluralName", "millennia" },
65-
{ "MillisecondPattern", "%n %u" },
66-
{ "MillisecondFuturePrefix", "" },
67-
{ "MillisecondFutureSuffix", " from now" },
68-
{ "MillisecondPastPrefix", "" },
69-
{ "MillisecondPastSuffix", " ago" },
70-
{ "MillisecondSingularName", "millisecond" },
71-
{ "MillisecondPluralName", "milliseconds" },
72-
{ "MinutePattern", "%n %u" },
73-
{ "MinuteFuturePrefix", "" },
74-
{ "MinuteFutureSuffix", " from now" },
75-
{ "MinutePastPrefix", "" },
76-
{ "MinutePastSuffix", " ago" },
77-
{ "MinuteSingularName", "minute" },
78-
{ "MinutePluralName", "minutes" },
79-
{ "MonthPattern", "%n %u" },
80-
{ "MonthFuturePrefix", "" },
81-
{ "MonthFutureSuffix", " from now" },
82-
{ "MonthPastPrefix", "" },
83-
{ "MonthPastSuffix", " ago" },
84-
{ "MonthSingularName", "month" },
85-
{ "MonthPluralName", "months" },
86-
{ "SecondPattern", "%n %u" },
87-
{ "SecondFuturePrefix", "" },
88-
{ "SecondFutureSuffix", " from now" },
89-
{ "SecondPastPrefix", "" },
90-
{ "SecondPastSuffix", " ago" },
91-
{ "SecondSingularName", "second" },
92-
{ "SecondPluralName", "seconds" },
93-
{ "WeekPattern", "%n %u" },
94-
{ "WeekFuturePrefix", "" },
95-
{ "WeekFutureSuffix", " from now" },
96-
{ "WeekPastPrefix", "" },
97-
{ "WeekPastSuffix", " ago" },
98-
{ "WeekSingularName", "week" },
99-
{ "WeekPluralName", "weeks" },
100-
{ "YearPattern", "%n %u" },
101-
{ "YearFuturePrefix", "" },
102-
{ "YearFutureSuffix", " from now" },
103-
{ "YearPastPrefix", "" },
104-
{ "YearPastSuffix", " ago" },
105-
{ "YearSingularName", "year" },
106-
{ "YearPluralName", "years" },
107-
{ "AbstractTimeUnitPattern", "" },
108-
{ "AbstractTimeUnitFuturePrefix", "" },
109-
{ "AbstractTimeUnitFutureSuffix", "" },
110-
{ "AbstractTimeUnitPastPrefix", "" },
111-
{ "AbstractTimeUnitPastSuffix", "" },
112-
{ "AbstractTimeUnitSingularName", "" },
113-
{ "AbstractTimeUnitPluralName", "" } };
22+
private static final Object[][] OBJECTS = new Object[][] {
23+
{ "CenturyPattern", "%n %u" },
24+
{ "CenturyFuturePrefix", "" },
25+
{ "CenturyFutureSuffix", " from now" },
26+
{ "CenturyPastPrefix", "" },
27+
{ "CenturyPastSuffix", " ago" },
28+
{ "CenturySingularName", "century" },
29+
{ "CenturyPluralName", "centuries" },
30+
{ "DayPattern", "%n %u" },
31+
{ "DayFuturePrefix", "" },
32+
{ "DayFutureSuffix", " from now" },
33+
{ "DayPastPrefix", "" },
34+
{ "DayPastSuffix", " ago" },
35+
{ "DaySingularName", "day" },
36+
{ "DayPluralName", "days" },
37+
{ "DecadePattern", "%n %u" },
38+
{ "DecadeFuturePrefix", "" },
39+
{ "DecadeFutureSuffix", " from now" },
40+
{ "DecadePastPrefix", "" },
41+
{ "DecadePastSuffix", " ago" },
42+
{ "DecadeSingularName", "decade" },
43+
{ "DecadePluralName", "decades" },
44+
{ "HourPattern", "%n %u" },
45+
{ "HourFuturePrefix", "" },
46+
{ "HourFutureSuffix", " from now" },
47+
{ "HourPastPrefix", "" },
48+
{ "HourPastSuffix", " ago" },
49+
{ "HourSingularName", "hour" },
50+
{ "HourPluralName", "hours" },
51+
{ "JustNowPattern", "%u" },
52+
{ "JustNowFuturePrefix", "" },
53+
{ "JustNowFutureSuffix", "moments from now" },
54+
{ "JustNowPastPrefix", "moments ago" },
55+
{ "JustNowPastSuffix", "" },
56+
{ "JustNowSingularName", "" },
57+
{ "JustNowPluralName", "" },
58+
{ "MillenniumPattern", "%n %u" },
59+
{ "MillenniumFuturePrefix", "" },
60+
{ "MillenniumFutureSuffix", " from now" },
61+
{ "MillenniumPastPrefix", "" },
62+
{ "MillenniumPastSuffix", " ago" },
63+
{ "MillenniumSingularName", "millennium" },
64+
{ "MillenniumPluralName", "millennia" },
65+
{ "MillisecondPattern", "%n %u" },
66+
{ "MillisecondFuturePrefix", "" },
67+
{ "MillisecondFutureSuffix", " from now" },
68+
{ "MillisecondPastPrefix", "" },
69+
{ "MillisecondPastSuffix", " ago" },
70+
{ "MillisecondSingularName", "millisecond" },
71+
{ "MillisecondPluralName", "milliseconds" },
72+
{ "MinutePattern", "%n %u" },
73+
{ "MinuteFuturePrefix", "" },
74+
{ "MinuteFutureSuffix", " from now" },
75+
{ "MinutePastPrefix", "" },
76+
{ "MinutePastSuffix", " ago" },
77+
{ "MinuteSingularName", "minute" },
78+
{ "MinutePluralName", "minutes" },
79+
{ "MonthPattern", "%n %u" },
80+
{ "MonthFuturePrefix", "" },
81+
{ "MonthFutureSuffix", " from now" },
82+
{ "MonthPastPrefix", "" },
83+
{ "MonthPastSuffix", " ago" },
84+
{ "MonthSingularName", "month" },
85+
{ "MonthPluralName", "months" },
86+
{ "SecondPattern", "%n %u" },
87+
{ "SecondFuturePrefix", "" },
88+
{ "SecondFutureSuffix", " from now" },
89+
{ "SecondPastPrefix", "" },
90+
{ "SecondPastSuffix", " ago" },
91+
{ "SecondSingularName", "second" },
92+
{ "SecondPluralName", "seconds" },
93+
{ "WeekPattern", "%n %u" },
94+
{ "WeekFuturePrefix", "" },
95+
{ "WeekFutureSuffix", " from now" },
96+
{ "WeekPastPrefix", "" },
97+
{ "WeekPastSuffix", " ago" },
98+
{ "WeekSingularName", "week" },
99+
{ "WeekPluralName", "weeks" },
100+
{ "YearPattern", "%n %u" },
101+
{ "YearFuturePrefix", "" },
102+
{ "YearFutureSuffix", " from now" },
103+
{ "YearPastPrefix", "" },
104+
{ "YearPastSuffix", " ago" },
105+
{ "YearSingularName", "year" },
106+
{ "YearPluralName", "years" },
107+
{ "AbstractTimeUnitPattern", "" },
108+
{ "AbstractTimeUnitFuturePrefix", "" },
109+
{ "AbstractTimeUnitFutureSuffix", "" },
110+
{ "AbstractTimeUnitPastPrefix", "" },
111+
{ "AbstractTimeUnitPastSuffix", "" },
112+
{ "AbstractTimeUnitSingularName", "" },
113+
{ "AbstractTimeUnitPluralName", "" } };
114114

115-
@Override
116-
public Object[][] getContents()
117-
{
118-
return OBJECTS;
119-
}
115+
@Override
116+
public Object[][] getContents()
117+
{
118+
return OBJECTS;
119+
}
120120

121121
}

0 commit comments

Comments
 (0)