diff --git a/cli/tests/test_revset_output.rs b/cli/tests/test_revset_output.rs index 5c3adde18d..dbcc4f5849 100644 --- a/cli/tests/test_revset_output.rs +++ b/cli/tests/test_revset_output.rs @@ -740,7 +740,7 @@ fn test_revset_committer_date_with_time_zone() { test_env.jj_cmd_ok( &repo_path, &[ - "--config=debug.commit-timestamp='2023-01-25T11:30:00-05:00'", + "--config=debug.commit-timestamp=2023-01-25T11:30:00-05:00", "describe", "-m", "first", @@ -749,7 +749,7 @@ fn test_revset_committer_date_with_time_zone() { test_env.jj_cmd_ok( &repo_path, &[ - "--config=debug.commit-timestamp='2023-01-25T12:30:00-05:00'", + "--config=debug.commit-timestamp=2023-01-25T12:30:00-05:00", "new", "-m", "second", @@ -758,7 +758,7 @@ fn test_revset_committer_date_with_time_zone() { test_env.jj_cmd_ok( &repo_path, &[ - "--config=debug.commit-timestamp='2023-01-25T13:30:00-05:00'", + "--config=debug.commit-timestamp=2023-01-25T13:30:00-05:00", "new", "-m", "third", @@ -768,7 +768,7 @@ fn test_revset_committer_date_with_time_zone() { let mut log_commits_before_and_after = |committer_date: &str, now: &str, tz: &str| -> (String, String) { test_env.add_env_var("TZ", tz); - let config = format!("debug.commit-timestamp='{now}'"); + let config = format!("debug.commit-timestamp={now}"); let before_log = test_env.jj_cmd_success( &repo_path, &[ diff --git a/lib/src/settings.rs b/lib/src/settings.rs index 7997017773..3571f52e74 100644 --- a/lib/src/settings.rs +++ b/lib/src/settings.rs @@ -125,12 +125,17 @@ impl SignSettings { } fn to_timestamp(value: ConfigValue) -> Result> { - // TODO: Maybe switch to native TOML date-time type? + // Since toml_edit::Datetime isn't the date-time type used across our code + // base, we accept both string and date-time types. if let Some(s) = value.as_str() { Ok(Timestamp::from_datetime(DateTime::parse_from_rfc3339(s)?)) + } else if let Some(d) = value.as_datetime() { + // It's easier to re-parse the TOML date-time expression. + let s = d.to_string(); + Ok(Timestamp::from_datetime(DateTime::parse_from_rfc3339(&s)?)) } else { let ty = value.type_name(); - Err(format!("invalid type: {ty}, expected a date-time string").into()) + Err(format!("invalid type: {ty}, expected a date-time").into()) } } diff --git a/lib/tests/test_operations.rs b/lib/tests/test_operations.rs index 852508924f..fbcfbe29c2 100644 --- a/lib/tests/test_operations.rs +++ b/lib/tests/test_operations.rs @@ -427,7 +427,7 @@ fn stable_op_id_settings() -> UserSettings { config.add_layer( ConfigLayer::parse( ConfigSource::User, - "debug.operation-timestamp = '2001-02-03T04:05:06+07:00'", + "debug.operation-timestamp = 2001-02-03T04:05:06+07:00", ) .unwrap(), );