Skip to content

Commit

Permalink
temp fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tonioriol committed Feb 22, 2024
1 parent 4ba7973 commit fa4bb22
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/lib/utils/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,25 @@ export const timeSince = (date: Date) => {
}
}

//returrn an objecct with { key: "today", label: "Today", isOpen: true }
export const categorizeDate = (chat: any): Chat | {} => {
export const categorizeDate = (): string => {
const now = new Date()
if (isToday(date)) {
if (isToday(now)) {
return 'today'
} else if (isYesterday(date)) {
} else if (isYesterday(now)) {
return 'yesterday'
} else if (
millisecondsPerDay < millisecondsSince(date) &&
millisecondsSince(date) <= previousSevenDays
millisecondsPerDay < millisecondsSince(now) &&
millisecondsSince(now) <= previousSevenDays
) {
return 'previousSevenDays'
} else if (
previousSevenDays < millisecondsSince(date) &&
millisecondsSince(date) <= lastThirtyDays
previousSevenDays < millisecondsSince(now) &&
millisecondsSince(now) <= lastThirtyDays
) {
return 'lastMonth'
} else if (date.getFullYear() <= currentYear) {
const year = date.getFullYear()
return year
} else if (now.getFullYear() <= currentYear) {
const year = now.getFullYear()
return year.toString()
} else {
return 'futureDate'
}
Expand Down

0 comments on commit fa4bb22

Please sign in to comment.