Skip to content

Commit d10529c

Browse files
committed
v1.0.2
1 parent 6d66e13 commit d10529c

File tree

16 files changed

+1359
-78
lines changed

16 files changed

+1359
-78
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,28 @@
33
**very** simple module that converts time. (Ex; ms -> seconds)
44

55
Documentation can be found in the [docs](/docs/globals.md) folder.
6+
7+
# Example
8+
9+
Here is an example of how to convert time:
10+
11+
```js
12+
import { convert, floorConvert, roundConvert } from '../build/index.js';
13+
14+
const time = { minutes: 300, seconds: 30, milliseconds: 500 }; // Units of time to convert
15+
16+
console.log(convert(time).hours); // 5.508472222222222
17+
console.log(roundConvert(time, 2).hours); // 5.01
18+
console.log(floorConvert(time).hours); // 5
19+
```
20+
21+
You can also use a chain to simplify adding and subtracting units of time.
22+
23+
```js
24+
import { ChainConvert } from '@jacobhumston/tc.js';
25+
26+
const chain = new ChainConvert();
27+
chain.add({ minutes: 1 }).subtract({ seconds: 30 }).add({ hours: 1 });
28+
29+
console.log(chain.floorConvert().seconds); // 3630
30+
```

docs/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,30 @@
55
# tc.js
66

77
**very** simple module that converts time. (Ex; ms -> seconds)
8+
9+
Documentation can be found in the [docs](/docs/globals.md) folder.
10+
11+
# Example
12+
13+
Here is an example of how to convert time:
14+
15+
```js
16+
import { convert, floorConvert, roundConvert } from '../build/index.js';
17+
18+
const time = { minutes: 300, seconds: 30, milliseconds: 500 }; // Units of time to convert
19+
20+
console.log(convert(time).hours); // 5.508472222222222
21+
console.log(roundConvert(time, 2).hours); // 5.01
22+
console.log(floorConvert(time).hours); // 5
23+
```
24+
25+
You can also use a chain to simplify adding and subtracting units of time.
26+
27+
```js
28+
import { ChainConvert } from '@jacobhumston/tc.js';
29+
30+
const chain = new ChainConvert();
31+
chain.add({ minutes: 1 }).subtract({ seconds: 30 }).add({ hours: 1 });
32+
33+
console.log(chain.floorConvert().seconds); // 3630
34+
```

0 commit comments

Comments
 (0)