From 0054d3b1a6a238f71186ad5f63d258deff7259a4 Mon Sep 17 00:00:00 2001 From: orbiter Date: Wed, 28 Sep 2005 22:54:31 +0000 Subject: [PATCH] added age in network menu git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@809 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/Network.html | 2 ++ htroot/Network.java | 3 +-- source/de/anomic/yacy/yacySeed.java | 12 ++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/htroot/Network.html b/htroot/Network.html index 95011abe1..9f8f4aa8c 100644 --- a/htroot/Network.html +++ b/htroot/Network.html @@ -43,6 +43,7 @@ #(complete)#:: Address
  Hash
  +Age
  #(/complete)# Type
  Release/
SVN

  @@ -71,6 +72,7 @@ :: http://#[ip]#:#[port]# #[hash]# +#[age]# #(/complete)# #(type)#junior::senior::principal#(/type)# #[version]# diff --git a/htroot/Network.java b/htroot/Network.java index e8fa4b2c7..f2888ae0d 100644 --- a/htroot/Network.java +++ b/htroot/Network.java @@ -293,8 +293,6 @@ public class Network { links = Long.parseLong(seed.get("LCount", "0")); words = Long.parseLong(seed.get("ICount", "0")); } catch (Exception exc) {links = 0; words = 0;} - prop.put(STR_TABLE_LIST+conCount+"_complete", ((complete)? 1 : 0) ); - prop.put(STR_TABLE_LIST+conCount+"_hash", seed.hash); String shortname = seed.get("Name", "deadlink"); if (shortname.length() > 20) { shortname = shortname.substring(0, 20) + "..."; @@ -306,6 +304,7 @@ public class Network { prop.put(STR_TABLE_LIST+conCount+"_complete_ip", seed.get("IP", "-") ); prop.put(STR_TABLE_LIST+conCount+"_complete_port", seed.get("Port", "-") ); prop.put(STR_TABLE_LIST+conCount+"_complete_hash", seed.hash); + prop.put(STR_TABLE_LIST+conCount+"_complete_age", seed.getAge()); }else{ prop.put(STR_TABLE_LIST+conCount+"_complete", 0); } diff --git a/source/de/anomic/yacy/yacySeed.java b/source/de/anomic/yacy/yacySeed.java index 0412836a6..d202f4e67 100644 --- a/source/de/anomic/yacy/yacySeed.java +++ b/source/de/anomic/yacy/yacySeed.java @@ -245,6 +245,18 @@ public class yacySeed { } } + public int getAge() { + // returns the age as number of days + try { + long t = yacyCore.shortFormatter.parse(get("BDate", "20040101000000")).getTime(); + return (int) ((System.currentTimeMillis() - (t - getUTCDiff() + serverDate.UTCDiff())) / 1000 / 60 / 60 / 24); + } catch (java.text.ParseException e) { + return -1; + } catch (java.lang.NumberFormatException e) { + return -1; + } + } + public void setLastSeenTime() { // if we set a last seen time, then we need to respect the seeds UTC offset put("LastSeen", yacyCore.shortFormatter.format(new Date(System.currentTimeMillis() - serverDate.UTCDiff() + getUTCDiff())));