Sha256: a1e3c8a28b507f8a9564f9ff20ac97072a2efe2104f1063e91de31273161f7d0

Contents?: true

Size: 1.17 KB

Versions: 69

Compression:

Stored size: 1.17 KB

Contents

# time #

Utilities for time manipulation.


## convert(value, sourceUnit, [destinationUnit]):Number

Converts time between units.

Available units: `millisecond`, `second`, `minute`, `hour`, `day`, `week`.
Abbreviations: `ms`, `s`, `m`, `h`, `d`, `w`.

We do **not** support year and month as a time unit since their values are not
fixed.

The default `destinationUnit` is `ms`.

```js
convert(1, 'minute');    // 60000
convert(2.5, 's', 'ms'); // 2500
convert(2, 'm', 's');    // 120
convert(500, 'ms', 's'); // 0.5
```



## now():Number

Returns the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC.
Uses `Date.now()` if available.

### Example

```js
now(); // 1335449614650
```



## parseMs(ms):Object

Parse timestamp (milliseconds) into an object `{milliseconds:number,
seconds:number, minutes:number, hours:number, days:number}`.

### Example

```js
// {days:27, hours:4, minutes:26, seconds:5, milliseconds:454}
parseMs(2348765454);
```



## toTimeString(ms):String

Convert timestamp (milliseconds) into a time string in the format "[H:]MM:SS".

### Example

```js
toTimeString(12513);   // "00:12"
toTimeString(951233);  // "15:51"
toTimeString(8765235); // "2:26:05"
```

Version data entries

69 entries across 69 versions & 2 rubygems

Version Path
trusty-festivity-extension-2.3.21 node_modules/bower/node_modules/mout/doc/time.md
trusty-festivity-extension-2.3.20 node_modules/bower/node_modules/mout/doc/time.md
trusty-festivity-extension-2.3.19 node_modules/bower/node_modules/mout/doc/time.md
trusty-festivity-extension-2.3.18 node_modules/bower/node_modules/mout/doc/time.md
trusty-festivity-extension-2.3.17 node_modules/bower/node_modules/mout/doc/time.md
trusty-festivity-extension-2.3.16 node_modules/bower/node_modules/mout/doc/time.md
trusty-festivity-extension-2.3.15 node_modules/bower/node_modules/mout/doc/time.md
trusty-festivity-extension-2.3.14 node_modules/bower/node_modules/mout/doc/time.md
trusty-festivity-extension-2.3.13 node_modules/bower/node_modules/mout/doc/time.md
trusty-festivity-extension-2.3.12 node_modules/bower/node_modules/mout/doc/time.md
trusty-festivity-extension-2.3.11g node_modules/bower/node_modules/mout/doc/time.md
trusty-festivity-extension-2.3.10 node_modules/bower/node_modules/mout/doc/time.md
trusty-festivity-extension-2.3.9 node_modules/bower/node_modules/mout/doc/time.md
trusty-festivity-extension-2.3.8 node_modules/bower/node_modules/mout/doc/time.md
trusty-festivity-extension-2.3.7 node_modules/bower/node_modules/mout/doc/time.md
trusty-festivity-extension-2.3.6 node_modules/bower/node_modules/mout/doc/time.md
trusty-festivity-extension-2.3.5 node_modules/bower/node_modules/mout/doc/time.md
trusty-festivity-extension-2.3.4 node_modules/bower/node_modules/mout/doc/time.md
trusty-festivity-extension-2.3.3 node_modules/bower/node_modules/mout/doc/time.md
trusty-festivity-extension-2.3.2 node_modules/bower/node_modules/mout/doc/time.md