Pull uncommitted work: relative time formatting tweaks (worktree 2d307dad)
Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
6f5dd37c93
commit
fab05c3ebe
3 files changed
+6
-5
No files matched your search
@@ -272,7 +272,7 @@ function ArchivedThreadRow(props: {
|
||||
</Text>
|
||||
<Text
|
||||
className="text-xs text-foreground-tertiary"
|
||||
style={{ fontVariant: ["tabular-nums"] }}
|
||||
style={{ fontVariant: ["tabular-nums"], minWidth: 30, textAlign: "right" }}
|
||||
>
|
||||
{timestamp}
|
||||
</Text>
|
||||
|
||||
@@ -370,7 +370,7 @@ function ThreadRow(props: {
|
||||
</View>
|
||||
<Text
|
||||
className="text-xs text-foreground-tertiary"
|
||||
style={{ fontVariant: ["tabular-nums"] }}
|
||||
style={{ fontVariant: ["tabular-nums"], minWidth: 30, textAlign: "right" }}
|
||||
>
|
||||
{timestamp}
|
||||
</Text>
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
export function relativeTime(input: string): string {
|
||||
const timestamp = Date.parse(input);
|
||||
if (Number.isNaN(timestamp)) {
|
||||
return "now";
|
||||
return "<1m";
|
||||
}
|
||||
|
||||
// Anything under a minute renders as "<1m" rather than a live seconds count.
|
||||
// The seconds ticker changed width every second and reflowed the surrounding row.
|
||||
const deltaSeconds = Math.max(0, Math.floor((Date.now() - timestamp) / 1000));
|
||||
if (deltaSeconds < 10) return "now";
|
||||
if (deltaSeconds < 60) return `${deltaSeconds}s`;
|
||||
if (deltaSeconds < 60) return "<1m";
|
||||
|
||||
const deltaMinutes = Math.floor(deltaSeconds / 60);
|
||||
if (deltaMinutes < 60) return `${deltaMinutes}m`;
|
||||
|
||||
Reference in new issue
Block a user