} 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) {
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;
}
if (post == null) {
continue;
}
- long age = now - post.getTime();
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())));
//
/**
- * Returns the formatted relative time for a given age.
+ * Returns the formatted relative time for a given time.
*
- * @param age
- * The age to format (in milliseconds)
+ * @param time
+ * The time to format the difference from (in milliseconds)
* @return The formatted age
*/
- private Time getTime(long age) {
- return getTime(webInterface, age);
+ private Time getTime(long time) {
+ return getTime(webInterface, time);
}
//
//
/**
- * Returns the formatted relative time for a given age.
+ * Returns the formatted relative time for a given time.
*
* @param webInterface
* The Sone web interface (for l10n access)
- * @param age
- * The age to format (in milliseconds)
+ * @param time
+ * The time to format the difference from (in milliseconds)
* @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) {