added last modified field
This commit is contained in:
19
src/functions/dateFomat.ts
Normal file
19
src/functions/dateFomat.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* Transforms the DateTime given from the api to a human readable format
|
||||
* @param date Date in ISO 8601 fomat
|
||||
*/
|
||||
function dateFormat(date:string | undefined | null): string {
|
||||
if (!date) return ""
|
||||
|
||||
const parsedDate = new Date(date)
|
||||
const now = new Date()
|
||||
|
||||
if (parsedDate.toDateString() === now.toDateString()){
|
||||
return parsedDate.toLocaleTimeString()
|
||||
}else{
|
||||
return parsedDate.toLocaleDateString()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default dateFormat
|
||||
Reference in New Issue
Block a user