1package soy.iko.opencode.ui.components
3import java.util.concurrent.TimeUnit
5/** Formats an epoch-millis timestamp as a short relative string (e.g. "3m", "2h", "5d"). */
6fun relativeTime(epochMillis: Long?): String {
7 if (epochMillis == null || epochMillis <= 0) return ""
8 val diff = System.currentTimeMillis() - epochMillis
9 if (diff < 0) return "now"
10 val minutes = TimeUnit.MILLISECONDS.toMinutes(diff)
11 if (minutes < 1) return "now"
12 if (minutes < 60) return "${minutes}m"
13 val hours = TimeUnit.MILLISECONDS.toHours(diff)
14 if (hours < 24) return "${hours}h"
15 val days = TimeUnit.MILLISECONDS.toDays(diff)
16 if (days < 7) return "${days}d"
18 if (weeks < 5) return "${weeks}w"
19 val months = days / 30
20 if (months < 12) return "${months}mo"
21 return "${days / 365}y"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list