3.0.3 • Published 2 years ago

clock-time v3.0.3

Weekly downloads
19
License
MIT
Repository
github
Last release
2 years ago

Clock Time

Build Status

Formats milliseconds or minutes and seconds as clock time

Installation

npm install clock-time

Usage

Import or require the package and pass milliseconds as a single argument to get nicely formatted clock time.

import clockTime from 'clock-time'; // es6
const clockTime = require('clock-time'); // cjs

clockTime(60 * 1000); // 1:00

Or, pass the number of minutes as the first argument and the number of seconds as the second argument instead.

clockTime(4, 20); // 4:20

toClockParts

Use the named export toClockParts to convert milliseconds to an object of minutes, zero-padded seconds, and total seconds. This can be useful when you want to use the parts of a clock time separately or in addition to the formatted string.

If the second argument to toClockParts is true, zero-padding on the returned seconds property will be disabled and seconds will be a number.

import {toClockParts} from 'clock-time';

const {
  minutes, // 4
  seconds, // 20
  total // 260
} = toClockParts(260000);

const formatted = `${minutes}:${seconds}`; // or clockTime(minutes, seconds)

License

MIT

3.0.3

2 years ago

3.0.2

4 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.3.1

5 years ago

2.3.0

5 years ago

2.2.4

5 years ago

2.2.3

5 years ago

2.2.2

6 years ago

2.2.1

6 years ago

2.2.0

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.5.1

6 years ago

1.5.0

6 years ago

1.4.0

6 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.1

7 years ago