This commit is contained in:
VividTruthKeeper 2022-09-22 16:46:01 +05:00
parent ddb7cd7209
commit 8cb57ddd18
3 changed files with 45 additions and 10 deletions

View File

@ -1,8 +1,19 @@
export const parseDate = (date: Date): string[] => { export const parseDate = (date: Date): string[] => {
const split = date.toString().split("T"); const split = date.toString().split("T");
const yyyy_mm_dd = split[0]; const yyyy_mm_dd = split[0];
const time = split[1].split("."); let time;
const hh_mm_ss = time[0]; let hh_mm_ss;
if (split[1].includes(".")) {
time = split[1].split(".");
// hh_mm_ss = time.pop();
hh_mm_ss = time[0];
} else {
time = split[1];
hh_mm_ss = time.slice(0, time.length - 1);
}
// console.log(time);
// time.slice(0, time.length - 1);
// console.log(time[time.length - 1]);
return [yyyy_mm_dd, hh_mm_ss]; return [yyyy_mm_dd, hh_mm_ss];
}; };

View File

@ -73,7 +73,13 @@ const Post = () => {
<input <input
type={"text"} type={"text"}
readOnly readOnly
value={postData ? parseDate(postData.publish_date)[0] : ""} value={
postData
? `${parseDate(postData.publish_date)[0]}, ${
parseDate(postData.publish_date)[1]
}`
: ""
}
/> />
</div> </div>
<div className="post__content__block"> <div className="post__content__block">
@ -116,13 +122,25 @@ const Post = () => {
<tr key={uuidv4()}> <tr key={uuidv4()}>
<td>{History.PostID}</td> <td>{History.PostID}</td>
<td> <td>
{parseDate(History.old_published_at)[0]} {`${
parseDate(History.old_published_at)[0]
}, ${
parseDate(History.old_published_at)[1]
}`}
</td> </td>
<td> <td>
{parseDate(History.new_published_at)[0]} {`${
parseDate(History.new_published_at)[0]
}, ${
parseDate(History.new_published_at)[1]
}`}
</td> </td>
<td>{parseDate(History.createdAt)[0]}</td> <td>{`${parseDate(History.createdAt)[0]}, ${
<td>{parseDate(History.updatedAt)[0]}</td> parseDate(History.createdAt)[1]
}`}</td>
<td>{`${parseDate(History.updatedAt)[0]}, ${
parseDate(History.updatedAt)[1]
}`}</td>
</tr> </tr>
); );
}) })

View File

@ -336,9 +336,15 @@ const Posts = () => {
<BiLinkExternal /> <BiLinkExternal />
</a> </a>
</td> </td>
<td>{parseDate(post.publish_date)[0]}</td> <td>{`${parseDate(post.publish_date)[0]}, ${
<td>{parseDate(post.createdAt)[0]}</td> parseDate(post.publish_date)[1]
<td>{parseDate(post.updatedAt)[0]}</td> }`}</td>
<td>{`${parseDate(post.createdAt)[0]}, ${
parseDate(post.createdAt)[1]
}`}</td>
<td>{`${parseDate(post.updatedAt)[0]}, ${
parseDate(post.updatedAt)[1]
}`}</td>
</tr> </tr>
</Link> </Link>
); );