11# TimeXt-JavaScript
22
33[ ![ Npm] ( https://img.shields.io/badge/npm-getit-red.svg )] ( https://www.npmjs.com/package/timext-js )
4- [ ![ Build] ( https://img.shields.io/badge/build-success-green.svg )] ( releases/timext-2019-05-26-1.min.js )
5- [ ![ Version] ( https://img.shields.io/badge/version-0.6.0-blue.svg )] ( releases )
6- [ ![ CodeCoverage] ( https://img.shields.io/badge/codeCoverage-99-green.svg )] ( coverage )
4+ [ ![ Build] ( https://img.shields.io/badge/build-success-green.svg )] ( releases/timext-2019-07-14-4.min.js )
5+ [ ![ Version] ( https://img.shields.io/badge/version-0.7.0-blue.svg )] ( releases )
6+
7+ [ ![ CodeCoverageStatements] ( https://img.shields.io/badge/Statements-100-green.svg )] ( coverage )
8+ [ ![ CodeCoverageBranch] ( https://img.shields.io/badge/Branch-77-yellow.svg )] ( coverage )
9+ [ ![ CodeCoverageFunctions] ( https://img.shields.io/badge/Functions-100-green.svg )] ( coverage )
10+ [ ![ CodeCoverageLines] ( https://img.shields.io/badge/Lines-100-green.svg )] ( coverage )
711
812[ ![ License: MIT] ( https://img.shields.io/badge/License-MIT-blue.svg )] ( https://opensource.org/licenses/MIT )
913[ ![ Paypal] ( https://img.shields.io/badge/paypal-donate-blue.svg )] ( https://www.paypal.me/GuepardoApps )
1014[ ![ PRs Welcome] ( https://img.shields.io/badge/PRs-welcome-brightgreen.svg )] ( http://makeapullrequest.com )
1115
1216First of all many thanks to [ Kizitonwose] ( https://github.com/kizitonwose/Time ) for the original idea and already awesome library!
1317
14- This minimized ( < 6kB ) library shall help to reduce code like
18+ This minimized ( [ ![ Size ] ( https://img.shields.io/badge/size-4KB-green.svg )] ( releases/timext-2019-07-14-4.min.js ) ) library shall help to reduce code like
1519
1620``` javascript
1721const dayInMillis = 24 * 60 * 60 * 1000 ; // Represent a day in milliSeconds
@@ -32,10 +36,10 @@ const threeDays = timext(3, u.D);
3236const elevenHours = timext (11 , u .H );
3337const sixMinutes = timext (6 , u .M );
3438const fiftySeconds = timext (50 , u .S );
35- const hundredMilliseconds = timext (100 , u .MS );
39+ const hundredMillis = timext (100 , u .MS );
3640
3741// Convert to other time units
38- const oneDayInMillis = timext (1 , u .D ).inMilliseconds (); // Converts one day into milliseconds
42+ const oneDayInMillis = timext (1 , u .D ).inMillis (); // Converts one day into milliseconds
3943const twoWeeksInHours = timext (2 , u .W ).inHours (); // Converts two weeks into hours
4044
4145// "operator" + - * /
@@ -58,10 +62,10 @@ const threeDays = Number(3).toDays(); // returns timext(3,
5862const elevenHours = Number (11 ).toHours (); // returns timext(11, u.H)
5963const sixMinutes = Number (6 ).toMinutes (); // returns timext(6, u.M)
6064const fiftySeconds = Number (50 ).toSeconds (); // returns timext(50, u.S)
61- const hundredMilliseconds = Number (100 ).toMilliseconds (); // returns timext(100, u.MS)
65+ const hundredMillis = Number (100 ).toMillis (); // returns timext(100, u.MS)
6266
6367// Return in other time units
64- const oneDayInMillis = Number (1 ).toDays ().inMilliseconds ();// Returns one day in milliseconds === 24 * 60 * 60 * 1e3
68+ const oneDayInMillis = Number (1 ).toDays ().inMillis (); // Returns one day in milliseconds === 24 * 60 * 60 * 1e3
6569const twoWeeksInHours = Number (2 ).toWeeks ().inHours (); // Returns two weeks in hours === 2 * 7 * 24
6670
6771// Convert to other time units
@@ -75,12 +79,14 @@ const threeWeeksAgo = Date.now.minus(Number(3).toWeeks());
7579```
7680
7781Since version 0.6.0 TimeXt has new extensions for the long type to display this number value in a human readable string format.
82+ Since version 0.7.0 TimeXt supports decimal numbers.
7883
7984``` javascript
80- const readableStringFromMilliseconds = Number (34325055574 ).formatMilliseconds () // 56 weeks, 5 days, 6 hours, 44 minutes, 15 seconds, 574 milliseconds
85+ const readableStringFromMillis = Number (34325055574 ).formatMillis () // 56 weeks, 5 days, 6 hours, 44 minutes, 15 seconds, 574 milliseconds
8186const readableStringFromSeconds = Number (4350554 ).formatSeconds () // 7 weeks, 1 day, 8 hours, 29 minutes, 14 seconds
8287const readableStringFromMinutes = Number (432555 ).formatMinutes () // 42 weeks, 6 days, 9 hours, 15 minutes
8388const readableStringFromHours = Number (4574 ).formatHours () // 27 weeks, 1 day, 14 hours
89+ const readableStringFromDays = Number (24.5 ).formatDays () // 3 weeks, 3 days, 12 hours
8490```
8591
8692## License
0 commit comments