-
Notifications
You must be signed in to change notification settings - Fork 30
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
1dd2f29
commit ac5957c
Showing
4 changed files
with
31 additions
and
25 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
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,24 @@ | ||
/** | ||
* Modify value according to a keyword. | ||
* Pass initial value if a keyword is not found. | ||
* @param {string} rawValue | ||
* @returns {string} | ||
*/ | ||
export const parseKeywordValue = (rawValue) => { | ||
const NOW_VALUE_KEYWORD = '$now$'; | ||
const CURRENT_DATE_KEYWORD = '$currentDate$'; | ||
|
||
let parsedValue; | ||
|
||
if (rawValue === NOW_VALUE_KEYWORD) { | ||
// Set to current time in ms, e.g 1667915146503 | ||
parsedValue = Date.now().toString(); | ||
} else if (rawValue === CURRENT_DATE_KEYWORD) { | ||
// Set to current date e.g 'Tue Nov 08 2022 13:53:19 GMT+0300' | ||
parsedValue = Date(); | ||
} else { | ||
parsedValue = rawValue; | ||
} | ||
|
||
return parsedValue; | ||
}; |
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