-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
1 changed file
with
50 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,50 @@ | ||
export const getDate = (date: string) => { | ||
const dateArr = date.split("-"); | ||
const year = dateArr[0]; | ||
const month = dateArr[1]; | ||
const day = dateArr[2]; | ||
const monthArr = [ | ||
"January", | ||
"February", | ||
"March", | ||
"April", | ||
"May", | ||
"June", | ||
"July", | ||
"August", | ||
"September", | ||
"October", | ||
"November", | ||
"December" | ||
]; | ||
//if undefined, return null | ||
if (monthArr[parseInt(month) - 1] === undefined) return ""; | ||
const monthName = monthArr[parseInt(month) - 1]; | ||
return `${monthName} ${day}, ${year}`; | ||
}; | ||
|
||
export const isNumeric = (val: string) : boolean => { | ||
return !isNaN(Number(val)); | ||
}; | ||
|
||
|
||
export const removeHTMLTags = (str: string) => { | ||
return str.replace(/<(?:.|\n)*?>/gm, "").replace(/\n/g, ""); | ||
}; | ||
|
||
export const removePlusFromStr = (str: string) => { | ||
return str.replace(/\(.*\)/g, "").replace(/,/g, "").trim(); | ||
}; | ||
|
||
export const keepPlusFromStr = (str: string) => { | ||
if (str.includes("---")) return null; | ||
return str.match(/\(.*\)/g)?.toString().replace(/[()]/g, ""); | ||
}; | ||
|
||
export const keepVoteNumbers = (str: string) => { | ||
return str.replace(/\(.*\)/g, "").replace(/,/g, "").trim(); | ||
}; | ||
|
||
export const matchAfterPlus = (str: string) => { | ||
return str.match(/\+[0-9]*/g)?.toString(); | ||
}; |