summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-09-18 12:11:06 +0000
committerGitHub <noreply@github.com>2022-09-18 12:11:06 +0000
commit19d6f1c72d1e6720a39f2b60cd6acb5a1b026e6f (patch)
tree0b70a656b22c01d52c26154bd3a4729ad8eade80
parent88e3ced7c2196532879a9fc20a9ded2a0f067cb6 (diff)
parenta4cc3a614ab080d4a6fb7d40e8b2d387c1b17b05 (diff)
Merge #94
94: Fix: Change filename timestamp format r=matthiasbeyer a=matthiasbeyer Backport the filename-timestamp-format fix to the release branch. Co-authored-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--Cargo.lock7
-rw-r--r--Cargo.toml2
-rw-r--r--src/command/new_command.rs9
3 files changed, 15 insertions, 3 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 5c55c9a..b05c6e3 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1110,9 +1110,16 @@ dependencies = [
"itoa",
"libc",
"num_threads",
+ "time-macros",
]
[[package]]
+name = "time-macros"
+version = "0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "42657b1a6f4d817cda8e7a0ace261fe0cc946cf3a80314390b22cc61ae080792"
+
+[[package]]
name = "tinyvec"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index 3e03a69..cce18fb 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -32,7 +32,7 @@ serde = { version = "1", features = [ "derive" ] }
serde_json = "1"
serde_yaml = "0.9.13"
thiserror = "1.0.35"
-time = { version = "0.3.14", features = [ "formatting" ] }
+time = { version = "0.3.14", features = [ "formatting", "macros" ] }
toml = "0.5.9"
typed-builder = "0.10.0"
walkdir = "2.3.2"
diff --git a/src/command/new_command.rs b/src/command/new_command.rs
index 2599572..9981aa1 100644
--- a/src/command/new_command.rs
+++ b/src/command/new_command.rs
@@ -39,8 +39,13 @@ impl crate::command::Command for NewCommand {
let new_file_name = format!(
"{ts}.md",
ts = {
- time::OffsetDateTime::now_utc()
- .format(&time::format_description::well_known::Iso8601::DEFAULT)?
+ // We cannot use the well-known formats here, because cargo cannot package
+ // filenames with ":" in it, but the well-known formats contain this character.
+ // Hence we have to use our own.
+ let fragment_file_timestamp_format = time::macros::format_description!(
+ "[year]-[month]-[day]T[hour]_[minute]_[second]_[subsecond]"
+ );
+ time::OffsetDateTime::now_utc().format(&fragment_file_timestamp_format)?
},
);
unreleased_dir_path.join(new_file_name)