-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
50 lines (35 loc) · 930 Bytes
/
utils.js
File metadata and controls
50 lines (35 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
function dateToString(dateString)
{
var date = new Date(dateString);
var month = date.getMonth() + 1;
if (month < 10) {month = "0" + month;}
var hours = date.getHours();
if (hours < 10) {hours = "0" + hours;}
var mins = date.getMinutes();
if (mins < 10){mins = "0" + mins;}
var secs = date.getSeconds();
if (secs < 10){secs = "0" + secs;}
return (date.getDate() + "/" + month + "/" + date.getFullYear() + " " + hours + ":" + mins + ":" + secs);
}
function getSquareRoot(x)
{
var s = 0;
var e = x;
var precision = 0.00001;
var m = (s + e)/2;
while (precision < (e - s))
{
m = (s + e)/2;
if (Math.pow(m,2) > x)
{
e = m;
}
else
{
s = m;
}
}
return m;
}
exports.dateToString = dateToString;
exports.getSquareRoot = getSquareRoot;