Update of /cvsroot/fudaa/fudaa_devel/ctulu/src/org/fudaa/ctulu
In directory sc8-pr-cvs1:/tmp/cvs-serv26970a
Modified Files:
CtuluLib.java
Log Message:
General update
Index: CtuluLib.java
===================================================================
RCS file: /cvsroot/fudaa/fudaa_devel/ctulu/src/org/fudaa/ctulu/CtuluLib.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** CtuluLib.java 12 Dec 2003 10:29:47 -0000 1.1
--- CtuluLib.java 19 Dec 2003 12:00:41 -0000 1.2
***************
*** 45,48 ****
--- 45,112 ----
}
+ public static long getDuration(
+ int _y,
+ int _m,
+ int _d,
+ int _h,
+ int _min,
+ int _s) {
+ return (long)_s
+ + (long)_min * 60l
+ + (long)_h * 3600l
+ + (long)_d * 86400
+ + (long)_m * 86400l * 30l
+ + (long)_y * 365l * 86400l;
+ }
+
+ /**
+ * initialise <code>_containter</code> avec [year,month,day,hour,minut,sec]:
+ * le tableau DOIT contenir au moins 6 rangs.
+ */
+ public static void getYearMonthDayTime(int[] _container, long _s) {
+ long d= 365 * 86400;
+ long timeRest= _s;
+ long value= timeRest / d;
+ _container[0]= (int)value;
+ if (value > 0) {
+ timeRest= timeRest - value * d;
+ }
+ d= 30 * 86400;
+ value= timeRest / d;
+ _container[1]= (int)value;
+ if (value > 0) {
+ timeRest= timeRest - value * d;
+ }
+ d= 86400;
+ value= timeRest / d;
+ _container[2]= (int)value;
+ if (value > 0) {
+ timeRest= timeRest - value * d;
+ }
+ d= 3600;
+ value= timeRest / d;
+ _container[3]= (int)value;
+ if (value > 0) {
+ timeRest= timeRest - value * d;
+ }
+ d= 60;
+ value= timeRest / d;
+ _container[4]= (int)value;
+ if (value > 0) {
+ timeRest= timeRest - value * d;
+ }
+ _container[5]= (int)timeRest;
+ }
+
+ /**
+ * @return un tableau a 6 rangee [year,month,day,hour,minut,sec] calcule a partir
+ * du temps _s
+ */
+ public static int[] getYearMonthDayTime(long _s) {
+ int[] r= new int[6];
+ getYearMonthDayTime(r, _s);
+ return r;
+ }
+
/**
*
***************
*** 105,109 ****
return getConanicalPathFile(new File(_baseDir, _path));
}
!
/**
* Renvoie le chemin canonique du fichier _f. Si une exception est levee
--- 169,173 ----
return getConanicalPathFile(new File(_baseDir, _path));
}
!
/**
* Renvoie le chemin canonique du fichier _f. Si une exception est levee
***************
*** 133,137 ****
return path;
}
!
/**
* Cherche l'index de la chaine <code>_string</code>
--- 197,201 ----
return path;
}
!
/**
* Cherche l'index de la chaine <code>_string</code>
***************
*** 153,157 ****
return -1;
}
!
/**
* Perment de déterminer le chemin relatif de _destFile par rapport a _baseDir. L'entier
--- 217,221 ----
return -1;
}
!
/**
* Perment de déterminer le chemin relatif de _destFile par rapport a _baseDir. L'entier
***************
*** 204,207 ****
--- 268,282 ----
}
+ public static void main(String[] args) {
+ int[] ymht=
+ getYearMonthDayTime(
+ 3600 * 3 + 60 * 4 + 1 + 3600 * 24 * 1 + 3600 * 24 * 30 * 18);
+ System.out.println("y=" + ymht[0]);
+ System.out.println("m=" + ymht[1]);
+ System.out.println("d=" + ymht[2]);
+ System.out.println("h=" + ymht[3]);
+ System.out.println("min=" + ymht[4]);
+ System.out.println("s=" + ymht[5]);
+ }
}
|