Skip to content

Show relative time ("N seconds/minutes ago (at HH:MM)") for recent clips#18

Open
faizanafz wants to merge 1 commit into
d7omdev:mainfrom
faizanafz:pr/relative-time-display
Open

Show relative time ("N seconds/minutes ago (at HH:MM)") for recent clips#18
faizanafz wants to merge 1 commit into
d7omdev:mainfrom
faizanafz:pr/relative-time-display

Conversation

@faizanafz
Copy link
Copy Markdown

Summary

Adds a relative-time label to the list row timestamp for clips recorded within the last hour. Older items are unchanged.

  • just now (at HH:MM) for < 5s
  • N seconds ago (at HH:MM) for < 60s
  • N minutes ago (at HH:MM) for < 1h
  • everything older keeps the existing Today at HH:MM / Yesterday at ... / date formats

The change is contained to clipse_gui/utils.py::format_date. Implemented by checking (now - dt).total_seconds() against 3600 before falling through to the existing date logic, so behavior for non-recent items is byte-identical.

Notes

  • The label is computed once when the row is built (same as before), so it does not tick live while the window stays open. Happy to add a periodic refresh if you'd prefer.
  • One-hour cutoff is hard-coded as < 3600; can be moved to a config value if useful.

Test plan

  • Manually verified with synthetic timestamps at 3s, 25s, 70s, 15min, 59min50s, 2h, and 2d.
  • Restarted local clipse-gui and confirmed labels render correctly in the GUI.

… the last hour

For clips recorded within the last 3600s, format_date now returns a relative
label paired with the wall-clock time, e.g. "25 seconds ago (at 22:38)" or
"15 minutes ago (at 20:24)". Older items keep the existing
Today/Yesterday/date formats.
@d7omdev
Copy link
Copy Markdown
Owner

d7omdev commented May 24, 2026

Thanks for the PR! A few things before merge:

  1. Tests fail. test_today_naive, test_z_suffix_treated_as_utc, and test_timezone_aware_iso all assert "Today at " for datetime.now() timestamps, which now fall into the new <3600s branch. They need updating, plus new tests for the boundaries (5s / 60s / 3600s) and singular/plural cases.
  2. Label goes stale. format_date runs once at row construction (list_row.py:241). Restoring from the tray (or just leaving the window open) never recomputes it, so "5 seconds ago" can sit there for 10 minutes. Needs a refresh_timestamp() on the row + a GLib.timeout_add_seconds(30, ...) tick while visible + a call on tray restore.
  3. Bug: "1 seconds ago" — seconds aren't pluralized like minutes are.
  4. Nit: negative delta_seconds (tiny clock skew) silently skips the new branch; consider abs() or treating small negatives as "just now".

Happy to re-review once tests pass and the label refreshes on show.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants