mirror of
https://github.com/gooba42/adventureland.git
synced 2026-10-14 10:33:47 -05:00
Merge pull request #176 from earthiverse/date-functions
improve date functions
This commit is contained in:
+19
-23
@@ -2005,35 +2005,31 @@ function html_escape(html)
|
|||||||
/*"*/
|
/*"*/
|
||||||
function he(html){return html_escape(html);}
|
function he(html){return html_escape(html);}
|
||||||
|
|
||||||
function future_ms(ms)
|
function future_ms(ms) {
|
||||||
{
|
return new Date(Date.now() + ms);
|
||||||
var c=new Date();
|
|
||||||
c.setUTCMilliseconds(c.getUTCMilliseconds()+ms);
|
|
||||||
return c;
|
|
||||||
}
|
}
|
||||||
function future_s(s)
|
function future_s(s) {
|
||||||
{
|
return future_ms(s * 1000);
|
||||||
var c=new Date();
|
|
||||||
c.setUTCSeconds(c.getUTCSeconds()+s);
|
|
||||||
return c;
|
|
||||||
}
|
}
|
||||||
function future_m(m)
|
function future_m(m) {
|
||||||
{
|
return future_ms(m * 60000);
|
||||||
return future_s(60*m);
|
|
||||||
}
|
}
|
||||||
function future_h(h)
|
function future_h(h) {
|
||||||
{
|
return future_ms(h * 3600000);
|
||||||
return future_m(60*h);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function mssince(t,ref)
|
function mssince(t, ref = Date.now()) {
|
||||||
{
|
return ref instanceof Date ? ref.getTime() - t.getTime() : ref - t.getTime();
|
||||||
if(!ref) ref=new Date();
|
}
|
||||||
return ref.getTime() - t.getTime();
|
function ssince(t, ref) {
|
||||||
|
return mssince(t, ref) / 1000;
|
||||||
|
}
|
||||||
|
function msince(t, ref) {
|
||||||
|
return mssince(t, ref) / 60000;
|
||||||
|
}
|
||||||
|
function hsince(t, ref) {
|
||||||
|
return mssince(t, ref) / 3600000;
|
||||||
}
|
}
|
||||||
function ssince(t,ref) { return mssince(t,ref)/1000.0; }
|
|
||||||
function msince(t,ref) { return mssince(t,ref)/60000.0; }
|
|
||||||
function hsince(t,ref) { return mssince(t,ref)/3600000.0; }
|
|
||||||
|
|
||||||
function sleep(ms)
|
function sleep(ms)
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@
|
|||||||
"node": true
|
"node": true
|
||||||
},
|
},
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"ecmaVersion": 10
|
"ecmaVersion": 2021
|
||||||
},
|
},
|
||||||
"plugins": ["prettier"],
|
"plugins": ["prettier"],
|
||||||
"rules": {
|
"rules": {
|
||||||
|
|||||||
Reference in New Issue
Block a user