UNPKG
itty-time
Version:
latest (2.0.2)
next (1.0.6-next.0)
2.0.2
2.0.1
2.0.0
1.0.6
1.0.6-next.0
1.0.5
1.0.5-next.1
1.0.5-next.0
1.0.4
1.0.3
1.0.2
1.0.0-next.5
1.0.0-next.4
1.0.0-next.3
1.0.0-next.2
1.0.0-next.1
1.0.0-next.0
0.2.2
0.2.1
0.2.0
0.1.8
0.1.7
0.1.6
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
Smaller and faster than ms.
github.com/kwhitley/itty-time
kwhitley/itty-time
itty-time
/
seconds.cjs
2 lines
(1 loc)
•
237 B
JavaScript
View Raw
1
2
"use strict"
;
const
e=
36e5
,s=
24
*e,t={
year
:
315576e5
,
month
:
30
*s,
week
:
7
*s,
day
:s,
hour
:e,
minute
:
6e4
,
second
:
1e3
,
m
:
1
};
exports
.
seconds
=
e
=>
(
e
=>
{
if
(!
isNaN
(+e))
return
+e;
const
[,s,n]=e.
match
(
/^([^ ]+) +(\w\w*?)s?$/
)||[,e];
return
+s*(t[n]||
1
)})(e)/
1e3
;