History

Merge pull request #1638 from tisonkun/allow-contructCustomFormat

Allow construct CustomFormat outside the crate

Sebastian Thiel committed 2 years ago

Commit bcdce6e2 parents b36d7ef 49109121 file · +8 −2Browse files

Unified · Split

gix-date/src/time/mod.rs+8−2
@@ -20,8 +20,7 @@ pub enum Sign { · 19 unmodified lines
2020 /// Various ways to describe a time format.
2121 #[derive(Debug, Clone, Copy)]
2222 pub enum Format {
23− /// A custom format limited to what's in the
24− /// [`format`](mod@crate::time::format) submodule.
23+ /// A custom format limited to what's in the [`format`](mod@format) submodule.
2524 Custom(CustomFormat),
2625 /// The seconds since 1970, also known as unix epoch, like `1660874655`.
2726 Unix,
@@ -33,6 +32,13 @@ pub enum Format { · 5 unmodified lines
3332 #[derive(Clone, Copy, Debug)]
3433 pub struct CustomFormat(pub(crate) &'static str);
3534
35+impl CustomFormat {
36+ /// Create a new custom `format` suitable for use with the [`jiff`] crate.
37+ pub const fn new(format: &'static str) -> Self {
38+ Self(format)
39+ }
40+}
41+
3642 impl From<CustomFormat> for Format {
3743 fn from(custom_format: CustomFormat) -> Format {
3844 Format::Custom(custom_format)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t