diff --git a/src/helpers/parseDate.ts b/src/helpers/parseDate.ts index 7475c40..ab7e361 100644 --- a/src/helpers/parseDate.ts +++ b/src/helpers/parseDate.ts @@ -1,8 +1,19 @@ export const parseDate = (date: Date): string[] => { const split = date.toString().split("T"); const yyyy_mm_dd = split[0]; - const time = split[1].split("."); - const hh_mm_ss = time[0]; + let time; + 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]; }; diff --git a/src/pages/Post.tsx b/src/pages/Post.tsx index c2c9c2e..2aa068e 100644 --- a/src/pages/Post.tsx +++ b/src/pages/Post.tsx @@ -73,7 +73,13 @@ const Post = () => {
@@ -116,13 +122,25 @@ const Post = () => { {History.PostID} - {parseDate(History.old_published_at)[0]} + {`${ + parseDate(History.old_published_at)[0] + }, ${ + parseDate(History.old_published_at)[1] + }`} - {parseDate(History.new_published_at)[0]} + {`${ + parseDate(History.new_published_at)[0] + }, ${ + parseDate(History.new_published_at)[1] + }`} - {parseDate(History.createdAt)[0]} - {parseDate(History.updatedAt)[0]} + {`${parseDate(History.createdAt)[0]}, ${ + parseDate(History.createdAt)[1] + }`} + {`${parseDate(History.updatedAt)[0]}, ${ + parseDate(History.updatedAt)[1] + }`} ); }) diff --git a/src/pages/Posts.tsx b/src/pages/Posts.tsx index ec53d01..4c84c32 100644 --- a/src/pages/Posts.tsx +++ b/src/pages/Posts.tsx @@ -336,9 +336,15 @@ const Posts = () => { - {parseDate(post.publish_date)[0]} - {parseDate(post.createdAt)[0]} - {parseDate(post.updatedAt)[0]} + {`${parseDate(post.publish_date)[0]}, ${ + parseDate(post.publish_date)[1] + }`} + {`${parseDate(post.createdAt)[0]}, ${ + parseDate(post.createdAt)[1] + }`} + {`${parseDate(post.updatedAt)[0]}, ${ + parseDate(post.updatedAt)[1] + }`} );