2.0.2 • Published 7 years ago

only-time v2.0.2

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

only-time

Library for time conversion from 24 hours clock system to number of minutes and seconds. Designed and used for transforming time before storing and after retrieving it from the database, when there is no need to store the whole date. Using numbers instead of strings not only save memory, but also let you perform comparison operations faster.

NOTE: toTime method is now obsolete, instead use fromMinutes (backward compatibility is ensured).

Installation

Install package via npm:

$ npm install --save only-time

Install package via yarn:

$ yarn add only-time

Usage

In Node.js application:

// Create new instance:
const OnlyTime = require('only-time');
const T = new OnlyTime();

In other applications, after including only-time.min.js file:

// Create new instance:
var T = new OnlyTime();

Sample conversion:

// Convert from time to minutes:
T.toMinutes('01:01'); // -> 61

// Convert from minutes to time:
T.fromMinutes(61); // -> '01:01'

// Convert from time to seconds:
T.toSeconds('01:02:03'); // -> 3723

// Convert from seconds to time:
T.fromSeconds(3723); // -> '01:02:03'

Separator

Default separator is set to :, but you can choose your own passing it as parameter while constructing object:

var T = new OnlyTime('.');

License

MIT

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.2.4

7 years ago

1.2.3

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago