projects
/
Sone.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
81d59ef
)
Return text for unknown date from accessor.
author
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Wed, 31 Aug 2011 04:00:22 +0000
(06:00 +0200)
committer
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Wed, 31 Aug 2011 04:00:22 +0000
(06:00 +0200)
src/main/java/net/pterodactylus/sone/template/SoneAccessor.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.java
patch
|
blob
|
history
diff --git
a/src/main/java/net/pterodactylus/sone/template/SoneAccessor.java
b/src/main/java/net/pterodactylus/sone/template/SoneAccessor.java
index
76fdcc1
..
ead6066
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/template/SoneAccessor.java
+++ b/
src/main/java/net/pterodactylus/sone/template/SoneAccessor.java
@@
-100,7
+100,7
@@
public class SoneAccessor extends ReflectionAccessor {
} else if (member.equals("locked")) {
return core.isLocked(sone);
} else if (member.equals("lastUpdatedText")) {
} else if (member.equals("locked")) {
return core.isLocked(sone);
} else if (member.equals("lastUpdatedText")) {
- return GetTimesAjaxPage.getTime((WebInterface) templateContext.get("webInterface"),
System.currentTimeMillis() -
sone.getTime());
+ return GetTimesAjaxPage.getTime((WebInterface) templateContext.get("webInterface"), sone.getTime());
} else if (member.equals("trust")) {
Sone currentSone = (Sone) templateContext.get("currentSone");
if (currentSone == null) {
} else if (member.equals("trust")) {
Sone currentSone = (Sone) templateContext.get("currentSone");
if (currentSone == null) {
diff --git
a/src/main/java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java
b/src/main/java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java
index
c55939d
..
f704905
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java
+++ b/
src/main/java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java
@@
-186,7
+186,7
@@
public class GetStatusAjaxPage extends JsonPage {
synchronized (dateFormat) {
jsonSone.put("lastUpdated", dateFormat.format(new Date(sone.getTime())));
}
synchronized (dateFormat) {
jsonSone.put("lastUpdated", dateFormat.format(new Date(sone.getTime())));
}
- jsonSone.put("lastUpdatedText", GetTimesAjaxPage.getTime(webInterface,
System.currentTimeMillis() -
sone.getTime()).getText());
+ jsonSone.put("lastUpdatedText", GetTimesAjaxPage.getTime(webInterface, sone.getTime()).getText());
return jsonSone;
}
return jsonSone;
}
diff --git
a/src/main/java/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.java
b/src/main/java/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.java
index
0be0c46
..
31ec399
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.java
+++ b/
src/main/java/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.java
@@
-62,9
+62,8
@@
public class GetTimesAjaxPage extends JsonPage {
if (post == null) {
continue;
}
if (post == null) {
continue;
}
- long age = now - post.getTime();
JsonObject postTime = new JsonObject();
JsonObject postTime = new JsonObject();
- Time time = getTime(
age
);
+ Time time = getTime(
post.getTime()
);
postTime.put("timeText", time.getText());
postTime.put("refreshTime", time.getRefresh() / Time.SECOND);
postTime.put("tooltip", dateFormat.format(new Date(post.getTime())));
postTime.put("timeText", time.getText());
postTime.put("refreshTime", time.getRefresh() / Time.SECOND);
postTime.put("tooltip", dateFormat.format(new Date(post.getTime())));
@@
-113,14
+112,14
@@
public class GetTimesAjaxPage extends JsonPage {
//
/**
//
/**
- * Returns the formatted relative time for a given
ag
e.
+ * Returns the formatted relative time for a given
tim
e.
*
*
- * @param
ag
e
- * The
age to format
(in milliseconds)
+ * @param
tim
e
+ * The
time to format the difference from
(in milliseconds)
* @return The formatted age
*/
* @return The formatted age
*/
- private Time getTime(long
ag
e) {
- return getTime(webInterface,
ag
e);
+ private Time getTime(long
tim
e) {
+ return getTime(webInterface,
tim
e);
}
//
}
//
@@
-128,15
+127,19
@@
public class GetTimesAjaxPage extends JsonPage {
//
/**
//
/**
- * Returns the formatted relative time for a given
ag
e.
+ * Returns the formatted relative time for a given
tim
e.
*
* @param webInterface
* The Sone web interface (for l10n access)
*
* @param webInterface
* The Sone web interface (for l10n access)
- * @param
ag
e
- * The
age to format
(in milliseconds)
+ * @param
tim
e
+ * The
time to format the difference from
(in milliseconds)
* @return The formatted age
*/
* @return The formatted age
*/
- public static Time getTime(WebInterface webInterface, long age) {
+ public static Time getTime(WebInterface webInterface, long time) {
+ if (time == 0) {
+ return new Time(webInterface.getL10n().getString("View.Sone.Text.UnknownDate"), 12 * Time.HOUR);
+ }
+ long age = System.currentTimeMillis() - time;
String text;
long refresh;
if (age < 0) {
String text;
long refresh;
if (age < 0) {