UNPKG

itty-time

Version:

Ultra-small (~390 bytes) library for TTL date math and converting ms durations to and from strings.

3 lines (2 loc) 241 B
"use strict";const e=36e5,t=24*e,r={year:315576e5,month:30*t,week:7*t,day:t,hour:e,minute:6e4,second:1e3,m:1};exports.ms=e=>{if(+e)return+e;const[,t,s]=e.match(/^([^ ]+) +(\w\w*?)s?$/)||[];return+t*(r[s]||1)}; //# sourceMappingURL=ms.js.map