alpha
Login
or
Join now
atpota.to
/
flushes.app
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
This repository has no description
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
relative timestamps
author
damedotblog
date
1 year ago
(Mar 8, 2025, 1:18 PM -0500)
commit
2d722b0f
2d722b0f9c618d25e5ffe6fd8356300b26767136
parent
792000b8
792000b85eb6dc2337e71b2a4293577824ef9360
+6
-54
3 changed files
Expand all
Collapse all
Unified
Split
app
src
app
page.tsx
lib
content-filter.ts
time-utils.ts
+3
-2
app/src/app/page.tsx
Reviewed
···
5
5
import { useRouter } from 'next/navigation';
6
6
import styles from './page.module.css';
7
7
import { useAuth } from '@/lib/auth-context';
8
8
-
import { containsBannedWords, sanitizeText, formatRelativeTime } from '@/lib/content-filter';
8
8
+
import { containsBannedWords, sanitizeText } from '@/lib/content-filter';
9
9
+
import { formatRelativeTime } from '@/lib/time-utils';
9
10
10
11
// Types for feed entries
11
12
interface FlushingEntry {
···
385
386
</span>
386
387
</div>
387
388
<span className={styles.timestamp}>
388
388
-
{new Date(entry.createdAt).toLocaleString()}
389
389
+
{formatRelativeTime(entry.createdAt)}
389
390
</span>
390
391
</div>
391
392
</div>
+1
-52
app/src/lib/content-filter.ts
Reviewed
···
147
147
return EXPLICIT_SLUR_REGEXES.some(regex => regex.test(text));
148
148
}
149
149
150
150
-
/**
151
151
-
* Formats a date into a relative time string (e.g., "5 minutes ago", "2 days ago")
152
152
-
* @param dateString The date string to format
153
153
-
* @returns A relative time string
154
154
-
*/
155
155
-
export function formatRelativeTime(dateString: string): string {
156
156
-
const date = new Date(dateString);
157
157
-
const now = new Date();
158
158
-
const diffInSeconds = Math.floor((now.getTime() - date.getTime()) / 1000);
159
159
-
160
160
-
// Less than a minute
161
161
-
if (diffInSeconds < 60) {
162
162
-
return 'just now';
163
163
-
}
164
164
-
165
165
-
// Less than an hour
166
166
-
if (diffInSeconds < 3600) {
167
167
-
const minutes = Math.floor(diffInSeconds / 60);
168
168
-
return `${minutes} ${minutes === 1 ? 'minute' : 'minutes'} ago`;
169
169
-
}
170
170
-
171
171
-
// Less than a day
172
172
-
if (diffInSeconds < 86400) {
173
173
-
const hours = Math.floor(diffInSeconds / 3600);
174
174
-
return `${hours} ${hours === 1 ? 'hour' : 'hours'} ago`;
175
175
-
}
176
176
-
177
177
-
// Less than a week
178
178
-
if (diffInSeconds < 604800) {
179
179
-
const days = Math.floor(diffInSeconds / 86400);
180
180
-
if (days === 1) {
181
181
-
return 'yesterday';
182
182
-
}
183
183
-
return `${days} days ago`;
184
184
-
}
185
185
-
186
186
-
// Less than a month
187
187
-
if (diffInSeconds < 2592000) {
188
188
-
const weeks = Math.floor(diffInSeconds / 604800);
189
189
-
return `${weeks} ${weeks === 1 ? 'week' : 'weeks'} ago`;
190
190
-
}
191
191
-
192
192
-
// Less than a year
193
193
-
if (diffInSeconds < 31536000) {
194
194
-
const months = Math.floor(diffInSeconds / 2592000);
195
195
-
return `${months} ${months === 1 ? 'month' : 'months'} ago`;
196
196
-
}
197
197
-
198
198
-
// More than a year
199
199
-
const years = Math.floor(diffInSeconds / 31536000);
200
200
-
return `${years} ${years === 1 ? 'year' : 'years'} ago`;
201
201
-
}
150
150
+
// Function removed and moved to time-utils.ts
+2
app/src/lib/time-utils.ts
Reviewed
···
1
1
export function formatRelativeTime(dateString: string): string {
2
2
+
if (!dateString) return '';
3
3
+
2
4
const date = new Date(dateString);
3
5
const now = new Date();
4
6
const diffInSeconds = Math.floor((now.getTime() - date.getTime()) / 1000);