/**
DateTime
-------
Author: Jamal BOUIZEM
Date: 20/02/2015
Version: 1.0.0
*/
var DateTime = (function(){
return {
instance: function(spec){
var that = {
h: spec.h || 0,
m: spec.m || 0,
s: spec.s || 0
};
var d = new Date();
var str = "";
function __init__(h, m, s)
{
that.h = h;
that.m = m;
that.s = s;
d.setHours(that.h);
d.setMinutes(that.m);
d.setSeconds(that.s);
};
that.get = function(){
d.setHours(that.h);
d.setMinutes(that.m);
d.setSeconds(that.s);
return d;
};
that.set = function(h, m, s){
__init__(h, m, s);
};
that.convertSecs = function(){
return (that.h * 3600) + (that.m * 60) + that.s;
};
that.secsToDate = function(seconds){
var ts = seconds % 60;
var tm = (seconds/60) % 60;
var th = (seconds/3600) % 60;
return DateTime.instance({ h: parseInt(th), m: parseInt(tm), s: parseInt(ts) });
};
that.add = function(d){
return that.secsToDate(that.convertSecs() + d.convertSecs());
};
that.subtract = function(d){
return that.secsToDate(that.convertSecs() - d.convertSecs());
};
__init__(that.h, that.m, that.s);
return that;
}
}
})();
¿Qué tipo de fecha y hora representan estos números en coma flotante? – deceze
Estos son una serie de segundos, comenzando desde cero. Es solo una serie de puntos representados por cuando ocurrieron. – jhanifen
Creo que el problema que estamos teniendo aquí es que los ejemplos que quiere convertir no tienen sentido. ¿Se supone que es la cantidad de segundos desde un punto específico en el tiempo (1.3 segundos después del 1 de enero de 1970?) –