Skip to content

Commit 6065c5b

Browse files
authored
Create parseMs.js
1 parent fa3ab87 commit 6065c5b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/Workspace/Resources/parseMs.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const { Workspace } = require('../index.js');
2+
3+
4+
Workspace.newF("parseMs", function(string) {
5+
if (typeof string != "string") {
6+
return parseFloat(string)*1000;
7+
}
8+
let t = string.split("");
9+
let thing = t.pop();
10+
11+
if (thing == "s") { return parseFloat(t.join(""))*1000; }
12+
else if (thing == "ms") { return parseFloat(t.join("")); }
13+
else if (thing == "m") { return parseFloat(t.join(""))*60*1000; }
14+
else if (thing == "h") { return parseFloat(t.join(""))*60*60*1000; }
15+
else if (thing == "d") { return parseFloat(t.join(""))*60*60*24*1000; }
16+
else if (thing == "w") { return parseFloat(t.join(""))*60*60*24*7*1000; }
17+
else if (thing == "y") { return parseFloat(t.join(""))*60*60*24*365*1000; }
18+
else { return parseFloat(string)*1000; }
19+
});

0 commit comments

Comments
 (0)