Skip to content

Commit

Permalink
fix: waline different date format cause formatting error
Browse files Browse the repository at this point in the history
  • Loading branch information
bennyxguo committed Aug 6, 2023
1 parent 517e9d0 commit 22477f2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/utils/comments/waline-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ export class WalineComments {
}

mapComment(comment: WalineComment): RecentComments {
const createdAt = formatTime(this.convertDateFormat(comment.insertedAt))
// slice off the last 5 character to remove the timezone.
const createdAt = formatTime(
new Date(comment.time).toISOString().slice(0, -5)
)
return {
id: comment.objectId,
body: filterHTMLContent(comment.comment),
Expand Down
1 change: 0 additions & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ export function filterHTMLContent(content: string, length?: number): string {
export function getDaysTillNow(from: string) {
const today = new Date()
const fromDate = new Date(from)
console.log(fromDate)

// To calculate the time difference of two dates
const timeDiff = today.getTime() - fromDate.getTime()
Expand Down

0 comments on commit 22477f2

Please sign in to comment.