Commit 048aa32
fix(datetime): floor sub-second negative timestamps instead of snapping to epoch (#262)
## Summary
`format_timestamp` converted `timestamp_ms → seconds` by integer
division, which truncates toward zero. Timestamps in the (-1000, 0) ms
window therefore collapsed onto the Unix epoch (1970-01-01 00:00:00)
instead of formatting as the preceding second (1969-12-31 23:59:59).
Swap `chrono::DateTime::from_timestamp(timestamp_ms / MS_TO_SECONDS, 0)`
for `chrono::DateTime::from_timestamp_millis(timestamp_ms)`, which takes
millisecond timestamps directly and floors correctly. The
`MS_TO_SECONDS` constant is no longer used.
## Test plan
- [x] `cargo test --lib utils::datetime` — 7 pass, including new
`format_datetime_small_negative_is_not_epoch` regression test
- [x] Existing positive-path tests (including sub-second
`format_datetime_rounds_down_sub_second`) still pass —
`from_timestamp_millis` produces the same formatted output for those
inputs
- [x] `cargo clippy -- -D warnings` clean
- [x] `cargo fmt --check` clean
Fixes #209.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- devin-review-badge-begin -->
---
<a href="https://app.devin.ai/review/usedetail/cli/pull/262"
target="_blank">
<picture>
<source media="(prefers-color-scheme: dark)"
srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1">
<img
src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1"
alt="Open in Devin Review">
</picture>
</a>
<!-- devin-review-badge-end -->
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent ed139d7 commit 048aa32
1 file changed
Lines changed: 13 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | 3 | | |
7 | 4 | | |
8 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
78 | 86 | | |
0 commit comments