diff --git a/clite/libtime.js b/clite/libtime.js index 8e104ff..45df3ff 100644 --- a/clite/libtime.js +++ b/clite/libtime.js @@ -28,6 +28,7 @@ clite.libs.load('libtime','time',function(io,env) { t = t.toString(); } clite.io.close(io.pid,fd); + console.log(t); return parseInt(t,10); } function genTime(time,tz) { @@ -74,12 +75,12 @@ return Object.create({ return genTime(time,tz); }, mktime:function(timeptr) { - var t = data.days[timeptr.tm_wday]+' '+data.months[timeptr.tm_mon]+' '+timeptr.tm_mday+' '+timeptr.tm_hour+':'+timeptr.tm_min+':'+timeptr.tm_sec+' '+(1900+timeptr.tm_year); - return (new Date(t)).getTime(); + var t = data.days[timeptr.tm_wday]+' '+data.months[timeptr.tm_mon]+' '+timeptr.tm_mday+' '+timeptr.tm_hour+':'+timeptr.tm_min+':'+timeptr.tm_sec+' '+(1900+timeptr.tm_year+' UTC'); + return parseInt(Math.floor((new Date(t)).getTime()/1000.0).toFixed(0)); }, time:function() { var t = readTime(); - return Math.floor(t/1000.0); // convert from milliseconds to seconds + return parseInt(Math.floor(t/1000.0).toFixed(0)); // convert from milliseconds to seconds } });