Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Lucas Silva
committed
Apr 20, 2021
1 parent
4544f0c
commit 3b12e73
Showing
41 changed files
with
843 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import requiredArgs from '../_lib/requiredArgs/index' | ||
/** | ||
* @name daysToWeeks | ||
* @category Common Helpers | ||
* @summary Convert days to weeks. | ||
* | ||
* @description | ||
* Convert days number to weeks numbers. | ||
* | ||
* @param { number } days - number of days to be converted. | ||
* | ||
* @returns {number} the number of days converted in weeks | ||
* @throws {TypeError} 1 argument required | ||
* | ||
* @example | ||
* //Converting 14 days to weeks | ||
* const result = daysToWeeks(14) => 2 | ||
*/ | ||
|
||
export default function daysToWeeks( | ||
days: number, | ||
|
||
): number { | ||
requiredArgs(1, arguments); | ||
|
||
const weeks = days/7; | ||
const weeksRounded = Number(Math.round(Number(weeks + "e" + 2)) + "e" + 2 * -1); //Precision of 2 in decimals | ||
|
||
return weeksRounded; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// @flow | ||
/* eslint-env mocha */ | ||
|
||
import assert from 'assert' | ||
import weeksToDays from '.' | ||
|
||
describe('weeksToDays', function() { | ||
it('converts weeks to days', function() { | ||
const result = weeksToDays(2); | ||
assert.deepStrictEqual(result, 14) | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import requiredArgs from '../_lib/requiredArgs/index' | ||
/** | ||
* @name hoursToMilliseconds | ||
* @category Common Helpers | ||
* @summary Convert hours to milliseconds. | ||
* | ||
* @description | ||
* Convert hours number to milliseconds numbers. | ||
* | ||
* @param { number } hours - number of hours to be converted. | ||
* | ||
* @returns {number} the number of hours converted in milliseconds | ||
* @throws {TypeError} 1 argument required | ||
* | ||
* @example | ||
* //Converting 2 hours to milliseconds | ||
* const result = hoursToMilliseconds(2) => 7,200,000 | ||
*/ | ||
|
||
export default function hoursToMilliseconds( | ||
hours: number, | ||
|
||
): number { | ||
requiredArgs(1, arguments); | ||
|
||
const MILLISECONDS_IN_1HOUR = 3600000; | ||
|
||
const milliseconds = hours * MILLISECONDS_IN_1HOUR; | ||
|
||
return milliseconds; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// @flow | ||
/* eslint-env mocha */ | ||
|
||
import assert from 'assert' | ||
import hoursToMilliseconds from '.' | ||
|
||
describe('hoursToMilliseconds', function() { | ||
it('converts hours to milliseconds', function() { | ||
const result = hoursToMilliseconds(2); | ||
assert.deepStrictEqual(result, 7200000) | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import requiredArgs from '../_lib/requiredArgs/index' | ||
/** | ||
* @name hoursToMinutes | ||
* @category Common Helpers | ||
* @summary Convert hours to minutes. | ||
* | ||
* @description | ||
* Convert hours number to minutes numbers. | ||
* | ||
* @param { number } hours - number of hours to be converted. | ||
* | ||
* @returns {number} the number of hours converted in minutes | ||
* @throws {TypeError} 1 argument required | ||
* | ||
* @example | ||
* //Converting 2 hours to minutes | ||
* const result = hoursToMinutes(2) => 120 | ||
*/ | ||
|
||
export default function hoursToMinutes( | ||
hours: number, | ||
|
||
): number { | ||
requiredArgs(1, arguments); | ||
|
||
return hours*60; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// @flow | ||
/* eslint-env mocha */ | ||
|
||
import assert from 'assert' | ||
import hoursToMinutes from '.' | ||
|
||
describe('hoursToMinutes', function() { | ||
it('converts hours to minutes', function() { | ||
const result = hoursToMinutes(2); | ||
assert.deepStrictEqual(result, 120) | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import requiredArgs from '../_lib/requiredArgs/index' | ||
/** | ||
* @name hoursToSeconds | ||
* @category Common Helpers | ||
* @summary Convert hours to seconds. | ||
* | ||
* @description | ||
* Convert hours number to seconds numbers. | ||
* | ||
* @param { number } hours - number of hours to be converted. | ||
* | ||
* @returns {number} the number of hours converted in seconds | ||
* @throws {TypeError} 1 argument required | ||
* | ||
* @example | ||
* //Converting 2 hours to seconds | ||
* const result = hoursToSeconds(2) => 7200 | ||
*/ | ||
|
||
export default function hoursToSeconds( | ||
hours: number, | ||
|
||
): number { | ||
requiredArgs(1, arguments); | ||
|
||
return hours * 3600; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// @flow | ||
/* eslint-env mocha */ | ||
|
||
import assert from 'assert' | ||
import hoursToSeconds from '.' | ||
|
||
describe('hoursToSeconds', function() { | ||
it('converts hours to minutes', function() { | ||
const result = hoursToSeconds(2); | ||
assert.deepStrictEqual(result, 7200) | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import requiredArgs from '../_lib/requiredArgs/index' | ||
/** | ||
* @name millisecondsToHours | ||
* @category Common Helpers | ||
* @summary Convert milliseconds to hours. | ||
* | ||
* @description | ||
* Convert milliseconds number to hours numbers. | ||
* | ||
* @param { number } milliseconds - number of milliseconds to be converted. | ||
* | ||
* @returns {number} the number of milliseconds converted in hours | ||
* @throws {TypeError} 1 argument required | ||
* | ||
* @example | ||
* //Converting 720000 milliseconds to hours | ||
* const result = millisecondsToHours(7200000) => 2 | ||
*/ | ||
|
||
export default function millisecondsToHours( | ||
milliseconds: number, | ||
|
||
): number { | ||
requiredArgs(1, arguments); | ||
|
||
const MILLISECONDS_IN_1HOUR = 3600000; | ||
|
||
const hours = milliseconds/MILLISECONDS_IN_1HOUR; | ||
const hoursRounded = Number(Math.round(Number(hours + "e" + 3)) + "e" + 3 * -1); //Precision of 3 in decimals | ||
|
||
return hoursRounded; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// @flow | ||
/* eslint-env mocha */ | ||
|
||
import assert from 'assert' | ||
import millisecondsToHours from '.' | ||
|
||
describe('millisecondsToHours', function() { | ||
it('converts milliseconds to hours', function() { | ||
const result = millisecondsToHours(7200000); | ||
assert.deepStrictEqual(result, 2) | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import requiredArgs from '../_lib/requiredArgs/index' | ||
/** | ||
* @name millisecondsToMinutes | ||
* @category Common Helpers | ||
* @summary Convert milliseconds to minutes. | ||
* | ||
* @description | ||
* //Converting milliseconds number to minutes numbers. | ||
* | ||
* @param { number } milliseconds - number of milliseconds to be converted. | ||
* | ||
* @returns {number} the number of milliseconds converted in minutes | ||
* @throws {TypeError} 1 argument required | ||
* | ||
* @example | ||
* //Converting 60000 milliseconds to minutes | ||
* const result = millisecondsToMinutes(60000) => 1 | ||
*/ | ||
|
||
export default function millisecondsToMinutes( | ||
milliseconds: number, | ||
|
||
): number { | ||
requiredArgs(1, arguments); | ||
|
||
const MILLISECONDS_IN_1MINUTE = 60000; | ||
|
||
const minutes = milliseconds/MILLISECONDS_IN_1MINUTE; | ||
const minutesRounded = Number(Math.round(Number(minutes + "e" + 3)) + "e" + 3 * -1); //Precision of 3 in decimals | ||
|
||
return minutesRounded; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// @flow | ||
/* eslint-env mocha */ | ||
|
||
import assert from 'assert' | ||
import millisecondsToMinutes from '.' | ||
|
||
describe('millisecondsToMinutes', function() { | ||
it('converts milliseconds to minutes', function() { | ||
const result = millisecondsToMinutes(120000); | ||
assert.deepStrictEqual(result, 2) | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import requiredArgs from '../_lib/requiredArgs/index' | ||
/** | ||
* @name millisecondsToSeconds | ||
* @category Common Helpers | ||
* @summary Convert milliseconds to seconds. | ||
* | ||
* @description | ||
* Convert milliseconds number to seconds numbers. | ||
* | ||
* @param { number } milliseconds - number of milliseconds to be converted. | ||
* | ||
* @returns {number} the number of milliseconds converted in seconds | ||
* @throws {TypeError} 1 argument required | ||
* | ||
* @example | ||
* //Converting 1000 miliseconds to seconds | ||
* const result = millisecondsToSeconds(1000) => 1 | ||
*/ | ||
|
||
export default function millisecondsToSeconds( | ||
milliseconds: number, | ||
|
||
): number { | ||
requiredArgs(1, arguments); | ||
|
||
const MILLISECONDS_IN_1SECOND = 1000; | ||
|
||
const seconds = milliseconds/MILLISECONDS_IN_1SECOND; | ||
|
||
const secondsRounded = Number(Math.round(Number(seconds + "e" + 3)) + "e" + 3 * -1); //Precision of 3 in decimals | ||
|
||
return secondsRounded; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// @flow | ||
/* eslint-env mocha */ | ||
|
||
import assert from 'assert' | ||
import millisecondsToSeconds from '.' | ||
|
||
describe('millisecondsToSeconds', function() { | ||
it('converts milliseconds to seconds', function() { | ||
const result = millisecondsToSeconds(3000); | ||
assert.deepStrictEqual(result, 3) | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import requiredArgs from '../_lib/requiredArgs/index' | ||
/** | ||
* @name minutesToHours | ||
* @category Common Helpers | ||
* @summary Convert minutes to hours. | ||
* | ||
* @description | ||
* Convert minutes number to hours numbers. | ||
* | ||
* @param { number } minutes - number of minutes to be converted. | ||
* | ||
* @returns {number} the number of minutes converted in hours | ||
* @throws {TypeError} 1 argument required | ||
* | ||
* @example | ||
* //Converting 140 minutes to hours | ||
* const result = minutesToHours(140) => 2.3 | ||
*/ | ||
|
||
export default function minutesToHours( | ||
minutes: number, | ||
|
||
): number { | ||
requiredArgs(1, arguments); | ||
|
||
const hours = minutes/60; | ||
const hoursRounded = Number(Math.round(Number(hours + "e" + 2)) + "e" + 2 * -1); //Precision of 2 in decimals | ||
|
||
return hoursRounded; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// @flow | ||
/* eslint-env mocha */ | ||
|
||
import assert from 'assert' | ||
import minuteToHours from '.' | ||
|
||
describe('minuteToHours', function() { | ||
it('converts minutes to hours', function() { | ||
const result = minuteToHours(140); | ||
assert.deepStrictEqual(result, 2.33) | ||
}); | ||
}); |
Oops, something went wrong.