📄 a couple updates
This commit is contained in:
46
lib/utils.ts
46
lib/utils.ts
@@ -1,18 +1,18 @@
|
||||
export function formatDate(dateString: string): string {
|
||||
const date = new Date(dateString)
|
||||
const months = [
|
||||
'ianuarie',
|
||||
'februarie',
|
||||
'martie',
|
||||
'aprilie',
|
||||
'mai',
|
||||
'iunie',
|
||||
'iulie',
|
||||
'august',
|
||||
'septembrie',
|
||||
'octombrie',
|
||||
'noiembrie',
|
||||
'decembrie',
|
||||
'January',
|
||||
'February',
|
||||
'March',
|
||||
'April',
|
||||
'May',
|
||||
'June',
|
||||
'July',
|
||||
'August',
|
||||
'September',
|
||||
'October',
|
||||
'November',
|
||||
'December',
|
||||
]
|
||||
|
||||
return `${date.getDate()} ${months[date.getMonth()]} ${date.getFullYear()}`
|
||||
@@ -24,12 +24,22 @@ export function formatRelativeDate(dateString: string): string {
|
||||
const diffTime = Math.abs(now.getTime() - date.getTime())
|
||||
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24))
|
||||
|
||||
if (diffDays === 0) return 'astăzi'
|
||||
if (diffDays === 1) return 'ieri'
|
||||
if (diffDays < 7) return `acum ${diffDays} zile`
|
||||
if (diffDays < 30) return `acum ${Math.floor(diffDays / 7)} săptămâni`
|
||||
if (diffDays < 365) return `acum ${Math.floor(diffDays / 30)} luni`
|
||||
return `acum ${Math.floor(diffDays / 365)} ani`
|
||||
if (diffDays === 0) return 'today'
|
||||
if (diffDays === 1) return 'yesterday'
|
||||
if (diffDays < 7) {
|
||||
const days = diffDays
|
||||
return `${days} day${days > 1 ? 's' : ''} ago`
|
||||
}
|
||||
if (diffDays < 30) {
|
||||
const weeks = Math.floor(diffDays / 7)
|
||||
return `${weeks} week${weeks > 1 ? 's' : ''} ago`
|
||||
}
|
||||
if (diffDays < 365) {
|
||||
const months = Math.floor(diffDays / 30)
|
||||
return `${months} month${months > 1 ? 's' : ''} ago`
|
||||
}
|
||||
const years = Math.floor(diffDays / 365)
|
||||
return `${years} year${years > 1 ? 's' : ''} ago`
|
||||
}
|
||||
|
||||
export function generateExcerpt(content: string, maxLength = 160): string {
|
||||
|
||||
Reference in New Issue
Block a user