Skip to content

Commit 5a61c13

Browse files
committed
config: default time range template is now absolute localtime + duration
1 parent 9d11428 commit 5a61c13

File tree

6 files changed

+15
-12
lines changed

6 files changed

+15
-12
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
2222
* `jj metaedit` now accepts `-m`/`--message` option to non-interactively update
2323
the change description.
2424

25+
* The default alias for formatting time ranges, used by `jj op log`,
26+
now shows the absolute local end time and duration.
27+
2528
### Fixed bugs
2629

2730
* `jj metaedit --author-timestamp` twice with the same value no longer

cli/src/config/templates.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ commit_summary_separator = 'label("separator", " | ")'
331331
# the moment when the repo was actually modified due to this operation. TODO:
332332
# This macro might need a better name, e.g. `format_operation_time_range`.
333333
'format_time_range(time_range)' = '''
334-
time_range.end().ago() ++ label("time", ", lasted ") ++ time_range.duration()'''
334+
format_timestamp(time_range.end()) ++ label("time", ", lasted ") ++ time_range.duration()'''
335335
'format_timestamp(timestamp)' = 'timestamp.local().format("%Y-%m-%d %H:%M:%S")'
336336

337337
'format_commit_summary_with_refs(commit, refs)' = '''

cli/tests/test_operations.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,9 +406,9 @@ fn test_op_log_template() {
406406
[EOF]
407407
"#);
408408

409-
// Test the default template, i.e. with relative start time and duration. We
410-
// don't generally use that template because it depends on the current time,
411-
// so we need to reset the time range format here.
409+
// Test a template with relative start time and duration, a previous default.
410+
// We don't generally use this style of template because it depends on the
411+
// current time, so we need to reset the time range format here.
412412
test_env.add_config(
413413
r#"
414414
[template-aliases]

docs/config.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -649,12 +649,12 @@ Can be customized by the `format_timestamp()` template alias.
649649
'format_timestamp(timestamp)' = 'timestamp.ago()'
650650
```
651651

652-
`jj op log` defaults to relative timestamps. To use absolute timestamps, you
653-
will need to modify the `format_time_range()` template alias.
652+
`jj op log` displays elapsed time with absolute local timestamps. To use relative
653+
timestamps, you will need to modify the `format_time_range()` template alias.
654654

655655
```toml
656656
[template-aliases]
657-
'format_time_range(time_range)' = 'time_range.start() ++ " - " ++ time_range.end()'
657+
'format_time_range(time_range)' = 'time_range.end().ago() ++ label("time", ", lasted ") ++ time_range.duration()'
658658
```
659659

660660
### Author format

docs/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ui.merge-editor = "meld" # default
2020
# ui.merge-editor = "kdiff3"
2121

2222
# Relative timestamp rendered as "x days/hours/seconds ago"
23-
template-aliases.'format_timestamp(timestamp)' = 'timestamp.ago()'
23+
# template-aliases.'format_timestamp(timestamp)' = 'timestamp.ago()'
2424

2525
# The four merge tools listed above are pre-configured. For detailed information
2626
# about how to change the default configuration or how to configure another tool,

docs/tutorial.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,16 +393,16 @@ commands to interact with it. To list the operations, use `jj op log`:
393393
394394
```shell
395395
$ jj op log
396-
@ d3b77addea49 [email protected] 3 minutes ago, lasted 3 milliseconds
396+
@ d3b77addea49 [email protected] 2025-05-12 00:27:27, lasted 3 milliseconds
397397
│ squash commits into f7fb5943a6b9460eb106dba2fac5cac1625c6f7a
398398
│ args: jj squash
399-
○ 6fc1873c1180 [email protected] 3 minutes ago, lasted 1 milliseconds
399+
○ 6fc1873c1180 [email protected] 2025-05-12 00:27:27, lasted 1 milliseconds
400400
│ snapshot working copy
401401
│ args: jj st
402-
○ ed91f7bcc1fb [email protected] 6 minutes ago, lasted 1 milliseconds
402+
○ ed91f7bcc1fb [email protected] 2025-05-12 00:24:21, lasted 1 milliseconds
403403
│ new empty commit
404404
│ args: jj new puqltutt
405-
○ 367400773f87 [email protected] 12 minutes ago, lasted 3 milliseconds
405+
○ 367400773f87 [email protected] 2025-05-12 00:18:08, lasted 3 milliseconds
406406
│ rebase commit daa6ffd5a09a8a7d09a65796194e69b7ed0a566d and descendants
407407
│ args: jj rebase -s puqltutt -d nuvyytnq
408408
[many more lines]

0 commit comments

Comments
 (0)