Skip to content

WIP: Add timeformat_display config key (relative/custom entry display) - #2117

Draft
alichtman wants to merge 1 commit into
mainfrom
timeformat-display-1721
Draft

alichtman wants to merge 1 commit into
mainfrom
timeformat-display-1721

Conversation

@alichtman

Copy link
Copy Markdown
Contributor

Summary

  • Adds a timeformat_display config key that controls how entry timestamps are displayed (jrnl -1, --short/-s, search results, etc.) independently of how they're stored (timeformat).
    • relative displays timestamps like 5 minutes ago / in 3 days.
    • Any other value is used as a strftime format string, same as timeformat.
    • Unset (default "") falls back to timeformat, so existing behavior is unchanged.
  • Fixes make_yaml_valid_dict() so --config-override timeformat_display '%d.%m.%Y' works — it previously raised a YAML ScannerError because a bare % is a reserved YAML indicator character. This matters here since the maintainer's comment on the issue calls out config-override as a supported way to set this.

Closes #1721

Test plan

  • poetry run poe test (lint + full suite): 720 passed, 40 skipped
  • New unit tests: tests/unit/test_time.py (relative_time), tests/unit/test_parse_args.py (make_yaml_valid_dict with %-containing values)
  • New BDD scenarios in tests/bdd/features/datetime.feature covering config-file and --config-override paths, relative, custom format strings, and --short/-s

Adds a "timeformat_display" config key that controls how entry
timestamps are shown (jrnl -1, --short/-s, search results) without
affecting how they're stored. It accepts "relative" (e.g. "5 minutes
ago") or a strftime format string, falling back to "timeformat" when
unset.

Also fixes make_yaml_valid_dict() to handle --config-override values
containing "%" (e.g. strftime formats), which previously raised a
YAML ScannerError since a bare "%" is a reserved YAML indicator.

Closes #1721

This branch has not been deployed

No deployments
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.

Add option to display relative dates/times

1 participant