Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM oven/bun:1.3.14

USER root

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
python3 \
make \
g++ \
git \
&& rm -rf /var/lib/apt/lists/*
6 changes: 6 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "17-313 OpenCode",
"build": {
"dockerfile": "Dockerfile"
}
}
27 changes: 15 additions & 12 deletions packages/tui/src/util/format.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
export function formatDuration(secs: number) {
if (secs <= 0) return ""
if (secs < 60) return `${secs}s`
if (secs < 3600) {
let result: string
if (secs <= 0) {
result = ""
} else if (secs < 60) {
result = `${secs}s`
} else if (secs < 3600) {
const mins = Math.floor(secs / 60)
const remaining = secs % 60
return remaining > 0 ? `${mins}m ${remaining}s` : `${mins}m`
}
if (secs < 86400) {
result = remaining > 0 ? `${mins}m ${remaining}s` : `${mins}m`
} else if (secs < 86400) {
const hours = Math.floor(secs / 3600)
const remaining = Math.floor((secs % 3600) / 60)
return remaining > 0 ? `${hours}h ${remaining}m` : `${hours}h`
}
if (secs < 604800) {
result = remaining > 0 ? `${hours}h ${remaining}m` : `${hours}h`
} else if (secs < 604800) {
const days = Math.floor(secs / 86400)
return days === 1 ? "~1 day" : `~${days} days`
result = days === 1 ? "~1 day" : `~${days} days`
} else {
const weeks = Math.floor(secs / 604800)
result = weeks === 1 ? "~1 week" : `~${weeks} weeks`
}
const weeks = Math.floor(secs / 604800)
return weeks === 1 ? "~1 week" : `~${weeks} weeks`
return result
}
Loading