`uptime`: uucore/get_uptime should return a `Duration`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 24.1k
- Forks
- 2k
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 365
Description
uucore's get_uptime function:
- Returns a signed integer value (but the uptime can't be a negative value?)
- Ignores fractional parts of a second even though the Linux kernel provides that in
/proc/uptime.
Possibly depending on the fractional timestamp value at boot time, the second point can cause a 1 second offset between GNU coreutils and uutils:
$ uptime --since
2025-04-23 18:26:36
$ cargo run -p uu_uptime -- --since
2025-04-23 18:26:37
I believe we should change the function signature to return a Duration.
Not sure how much we care about semver in uucore, we would need to modify procps/uu_top as well: see https://github.com/uutils/coreutils/pull/7289.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at uucore's get_uptime function and trace its callers in procps and uu_top, as noted in the issue. Check the uu_uptime --since path and the linked behavior against GNU coreutils. Done means the API represents non-negative fractional uptime with Duration and all affected callers compile and preserve the expected timestamp.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100