Skip to content

Commit fa3ab87

Browse files
authored
Create parseTime.js
1 parent 675f7ae commit fa3ab87

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
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("parseTime", function(string) {
5+
if (typeof string != "string") {
6+
return parseFloat(string);
7+
}
8+
let t = string.split("");
9+
let thing = t.pop();
10+
11+
if (thing == "s") { return parseFloat(t.join("")); }
12+
else if (thing == "ms") { return parseFloat(t.join(""))*1000; }
13+
else if (thing == "m") { return parseFloat(t.join(""))*60; }
14+
else if (thing == "h") { return parseFloat(t.join(""))*60*60; }
15+
else if (thing == "d") { return parseFloat(t.join(""))*60*60*24; }
16+
else if (thing == "w") { return parseFloat(t.join(""))*60*60*24*7; }
17+
else if (thing == "y") { return parseFloat(t.join(""))*60*60*24*365; }
18+
else { return parseFloat(string); }
19+
});

0 commit comments

Comments
 (0)