source: trip-planner-front/node_modules/ms/readme.md@ 1ad8e64

Last change on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.0 KB
Line 
1# ms
2
3[![Build Status](https://travis-ci.org/zeit/ms.svg?branch=master)](https://travis-ci.org/zeit/ms)
4[![Join the community on Spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/zeit)
5
6Use this package to easily convert various time formats to milliseconds.
7
8## Examples
9
10```js
11ms('2 days') // 172800000
12ms('1d') // 86400000
13ms('10h') // 36000000
14ms('2.5 hrs') // 9000000
15ms('2h') // 7200000
16ms('1m') // 60000
17ms('5s') // 5000
18ms('1y') // 31557600000
19ms('100') // 100
20ms('-3 days') // -259200000
21ms('-1h') // -3600000
22ms('-200') // -200
23```
24
25### Convert from Milliseconds
26
27```js
28ms(60000) // "1m"
29ms(2 * 60000) // "2m"
30ms(-3 * 60000) // "-3m"
31ms(ms('10 hours')) // "10h"
32```
33
34### Time Format Written-Out
35
36```js
37ms(60000, { long: true }) // "1 minute"
38ms(2 * 60000, { long: true }) // "2 minutes"
39ms(-3 * 60000, { long: true }) // "-3 minutes"
40ms(ms('10 hours'), { long: true }) // "10 hours"
41```
42
43## Features
44
45- Works both in [Node.js](https://nodejs.org) and in the browser
46- If a number is supplied to `ms`, a string with a unit is returned
47- If a string that contains the number is supplied, it returns it as a number (e.g.: it returns `100` for `'100'`)
48- If you pass a string with a number and a valid unit, the number of equivalent milliseconds is returned
49
50## Related Packages
51
52- [ms.macro](https://github.com/knpwrs/ms.macro) - Run `ms` as a macro at build-time.
53
54## Caught a Bug?
55
561. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device
572. Link the package to the global module directory: `npm link`
583. Within the module you want to test your local development instance of ms, just link it to the dependencies: `npm link ms`. Instead of the default one from npm, Node.js will now use your clone of ms!
59
60As always, you can run the tests using: `npm test`
Note: See TracBrowser for help on using the repository browser.