-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
7e02f58
commit 47e2e0c
Showing
5 changed files
with
327 additions
and
1 deletion.
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,57 @@ | ||
/** | ||
* Handlebars Array Helpers | ||
* | ||
* @source https://github.com/helpers/handlebars-helpers | ||
* | ||
* @package kzarshenas/crazyphp | ||
* @author kekefreedog <[email protected]> | ||
* @copyright 2022-2024 Kévin Zarshenas | ||
*/ | ||
|
||
/** | ||
* Multiply | ||
* | ||
* Multiply a with b | ||
* | ||
* @param a value | ||
* @param b value | ||
* @param Object options | ||
* | ||
* @return number | ||
*/ | ||
module.exports = (date, options) => { | ||
|
||
// Check date given | ||
if (typeof date !== 'string' || isNaN(Date.parse(date))) | ||
|
||
// Return the input if it is not a valid date string | ||
return date; | ||
|
||
// Date instance | ||
const givenDate = new Date(date); | ||
|
||
// Today instance | ||
const today = new Date(); | ||
|
||
// Set time to 00:00:00 to only compare dates | ||
today.setHours(0, 0, 0, 0); | ||
|
||
// In past | ||
if(givenDate < today) | ||
|
||
//Date is in the past | ||
return -1; | ||
|
||
else | ||
// Future | ||
if(givenDate > today) | ||
|
||
// Date is in the future | ||
return 1; | ||
|
||
else | ||
|
||
// Date is today | ||
return 0; | ||
|
||
} |
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,35 @@ | ||
/** | ||
* Handlebars Array Helpers | ||
* | ||
* @source https://github.com/helpers/handlebars-helpers | ||
* | ||
* @package kzarshenas/crazyphp | ||
* @author kekefreedog <[email protected]> | ||
* @copyright 2022-2024 Kévin Zarshenas | ||
*/ | ||
|
||
/** | ||
* Divide | ||
* | ||
* Divide a by b | ||
* | ||
* @param a value | ||
* @param b value | ||
* @param Object options | ||
* | ||
* @return number | ||
*/ | ||
module.exports = (a, b, options) => { | ||
|
||
// Check if array or string | ||
if((!isNaN(parseFloat(a)) && isFinite(a)) && (!isNaN(parseFloat(b)) && isFinite(b)) && Number(b) != 0) | ||
|
||
// Return length | ||
return Number($a) / Number($b); | ||
|
||
else | ||
|
||
// Return string | ||
return `${a}/${b}`; | ||
|
||
} |
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,35 @@ | ||
/** | ||
* Handlebars Array Helpers | ||
* | ||
* @source https://github.com/helpers/handlebars-helpers | ||
* | ||
* @package kzarshenas/crazyphp | ||
* @author kekefreedog <[email protected]> | ||
* @copyright 2022-2024 Kévin Zarshenas | ||
*/ | ||
|
||
/** | ||
* Multiply | ||
* | ||
* Multiply a with b | ||
* | ||
* @param a value | ||
* @param b value | ||
* @param Object options | ||
* | ||
* @return number | ||
*/ | ||
module.exports = (a, b, options) => { | ||
|
||
// Check if array or string | ||
if((!isNaN(parseFloat(a)) && isFinite(a)) && (!isNaN(parseFloat(b)) && isFinite(b))) | ||
|
||
// Return length | ||
return Number($a) * Number($b); | ||
|
||
else | ||
|
||
// Return string | ||
return `${a}*${b}`; | ||
|
||
} |
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