Skip to content

Commit

Permalink
Merge pull request #1638 from tisonkun/allow-contructCustomFormat
Browse files Browse the repository at this point in the history
Allow construct CustomFormat outside the crate
  • Loading branch information
Byron authored Oct 21, 2024
2 parents b36d7ef + 4910912 commit bcdce6e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions gix-date/src/time/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -33,6 +32,13 @@ pub enum Format {
#[derive(Clone, Copy, Debug)]
pub struct CustomFormat(pub(crate) &'static str);

impl CustomFormat {
/// Create a new custom `format` suitable for use with the [`jiff`] crate.
pub const fn new(format: &'static str) -> Self {
Self(format)
}
}

impl From<CustomFormat> for Format {
fn from(custom_format: CustomFormat) -> Format {
Format::Custom(custom_format)
Expand Down

0 comments on commit bcdce6e

Please sign in to comment.