From 4b20bd1a8da30eb2ed88adb390e5cf7994779556 Mon Sep 17 00:00:00 2001 From: tison Date: Mon, 21 Oct 2024 14:15:09 +0800 Subject: [PATCH 1/2] feat: add `CustomFormat::new()` to allow construction. --- gix-date/src/time/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gix-date/src/time/mod.rs b/gix-date/src/time/mod.rs index 4d9f9974dbf..cc6d91bb859 100644 --- a/gix-date/src/time/mod.rs +++ b/gix-date/src/time/mod.rs @@ -33,6 +33,13 @@ pub enum Format { #[derive(Clone, Copy, Debug)] pub struct CustomFormat(pub(crate) &'static str); +impl CustomFormat { + /// Create a new custom format. + pub const fn new(format: &'static str) -> Self { + Self(format) + } +} + impl From for Format { fn from(custom_format: CustomFormat) -> Format { Format::Custom(custom_format) From 4910912e2b4957350a7ab8169ba9de956e8d8325 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 21 Oct 2024 09:51:43 +0200 Subject: [PATCH 2/2] refactor - improve docs --- gix-date/src/time/mod.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gix-date/src/time/mod.rs b/gix-date/src/time/mod.rs index cc6d91bb859..b403decdf88 100644 --- a/gix-date/src/time/mod.rs +++ b/gix-date/src/time/mod.rs @@ -20,8 +20,7 @@ pub enum Sign { /// Various ways to describe a time format. #[derive(Debug, Clone, Copy)] pub enum Format { - /// A custom format limited to what's in the - /// [`format`](mod@crate::time::format) submodule. + /// A custom format limited to what's in the [`format`](mod@format) submodule. Custom(CustomFormat), /// The seconds since 1970, also known as unix epoch, like `1660874655`. Unix, @@ -34,7 +33,7 @@ pub enum Format { pub struct CustomFormat(pub(crate) &'static str); impl CustomFormat { - /// Create a new custom format. + /// Create a new custom `format` suitable for use with the [`jiff`] crate. pub const fn new(format: &'static str) -> Self { Self(format) }