mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-24 20:54:15 +00:00
Add UTC format for timestamp formats. Thanks to @rauljordan for these changes.
Add tests for new UTC timestamp format Add documentation for timestamp utc Update CHANGELOG.md
This commit is contained in:
parent
5bd726f77d
commit
ac5d8eb784
4 changed files with 23 additions and 0 deletions
|
@ -90,6 +90,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
* Revsets gained a new function `mine()` that aliases `author(exact:"your_email")`.
|
||||
|
||||
* `jj log` timestamp format now accepts `.utc()` to convert a timestamp to UTC.
|
||||
|
||||
### Fixed bugs
|
||||
|
||||
* `jj config set --user` and `jj config edit --user` can now be used outside of any repository.
|
||||
|
|
|
@ -448,6 +448,13 @@ fn build_timestamp_method<'a, L: TemplateLanguage<'a>>(
|
|||
time_util::format_absolute_timestamp_with(×tamp, &format)
|
||||
}))
|
||||
}
|
||||
"utc" => {
|
||||
template_parser::expect_no_arguments(function)?;
|
||||
language.wrap_timestamp(TemplateFunction::new(self_property, |mut timestamp| {
|
||||
timestamp.tz_offset = 0;
|
||||
timestamp
|
||||
}))
|
||||
}
|
||||
_ => return Err(TemplateParseError::no_such_method("Timestamp", function)),
|
||||
};
|
||||
Ok(property)
|
||||
|
|
|
@ -110,6 +110,19 @@ fn test_log_author_timestamp_ago() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_log_author_timestamp_utc() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.jj_cmd_success(test_env.env_root(), &["init", "repo", "--git"]);
|
||||
let repo_path = test_env.env_root().join("repo");
|
||||
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-T", "author.timestamp().utc()"]);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
@ 2001-02-02 21:05:07.000 +00:00
|
||||
◉ 1970-01-01 00:00:00.000 +00:00
|
||||
"###);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_log_default() {
|
||||
let test_env = TestEnvironment::default();
|
||||
|
|
|
@ -154,6 +154,7 @@ The following methods are defined.
|
|||
* `.ago() -> String`: Format as relative timestamp.
|
||||
* `.format(format: String) -> String`: Format with [the specified strftime-like
|
||||
format string](https://docs.rs/chrono/latest/chrono/format/strftime/).
|
||||
* `.utc() -> Timestamp`: Convert timestamp into UTC timezone.
|
||||
|
||||
### TimestampRange type
|
||||
|
||||
|
|
Loading…
Reference in a new issue