diff --git a/src/fr/devinsy/util/SimpleChronometer.java b/src/fr/devinsy/util/SimpleChronometer.java old mode 100755 new mode 100644 index c172db6..4da6eba --- a/src/fr/devinsy/util/SimpleChronometer.java +++ b/src/fr/devinsy/util/SimpleChronometer.java @@ -47,4 +47,103 @@ public class SimpleChronometer // return(result); } + + + /** + * + */ + static public String shortHumanString(long interval) + { + String result; + + if (interval < 1000) + { + result = interval + " ms"; + } + else if (interval < 60*1000) + { + result = interval/1000 + " s"; + } + else if (interval < 60*60*1000L) + { + result = interval/(60*1000L) + " mn"; + } + else if (interval < 2*60*60*1000L) + { + result = interval/(60*1000L) + " heure"; + } + else if (interval < 24*60*60*1000L) + { + result = interval/(60*60*1000L) + " heures"; + } + else if (interval < 2*24*60*60*1000L) + { + result = interval/(24*60*60*1000L) + " jour"; + } + else if (interval < 7*24*60*60*1000L) + { + result = interval/(24*60*60*1000L) + " jours"; + } + else if (interval < 2*7*24*60*60*1000L) + { + result = interval/(7*24*60*60*1000L) + " semaine"; + } + else if (interval < 30*24*60*60*1000L) + { + result = interval/(7*24*60*60*1000L) + " semaines"; + } + else if (interval < 52*7*24*60*60*1000L) + { + result = interval/(30*24*60*60*1000L) + " mois"; + } + else if (interval < 2*52*7*24*60*60*1000L) + { + result = interval/(52*7*24*60*60*1000L) + " année"; + } + else + { + result = interval/(52*7*24*60*60*1000L) + " années"; + } + + + // + return(result); + } + + + /** + * TO BE COMPLETED. + */ + static public String humanString(long interval) + { + String result; + + if (interval < 1000) + { + result = interval + "ms"; + } + else if (interval < 60*1000) + { + result = interval/1000 + "," + interval%1000 + "s"; + } + else if (interval < 60*60*1000) + { + result = interval/1000 + "," + interval%1000 + "s"; + } + else if (interval < 24*60*60*1000) + { + result = interval/1000 + "," + interval%1000 + "s"; + } + else if (interval < 7*24*60*60*1000) + { + result = interval/1000 + "," + interval%1000 + "s"; + } + else // if (interval < 7*24*60*60*1000) + { + result = interval/1000 + "," + interval%1000 + "s"; + } + + // + return(result); + } }