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.1 node_modules/bower/node_modules/mout/doc/time.md
trusty-festivity-extension-2.3.0 node_modules/bower/node_modules/mout/doc/time.md
entangled-0.0.16 spec/dummy/public/node_modules/bower/node_modules/mout/doc/time.md
entangled-0.0.15 spec/dummy/public/node_modules/bower/node_modules/mout/doc/time.md
entangled-0.0.14 spec/dummy/public/node_modules/bower/node_modules/mout/doc/time.md
entangled-0.0.13 spec/dummy/public/node_modules/bower/node_modules/mout/doc/time.md
entangled-0.0.12 spec/dummy/public/node_modules/bower/node_modules/mout/doc/time.md
entangled-0.0.11 spec/dummy/public/node_modules/bower/node_modules/mout/doc/time.md
entangled-0.0.10 spec/dummy/public/node_modules/bower/node_modules/mout/doc/time.md