Skip to content

Commit

Permalink
style(dtt): 🎨 Improved Organization, add more detailed comments etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienrousseau committed May 5, 2024
1 parent d9be125 commit f472d17
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,30 @@ use time::{Duration, Month, OffsetDateTime, UtcOffset};
/// The `macros` module contains functions for generating macros.
pub mod macros;

/// Custom error type for DateTime parsing.
#[derive(Debug)]
pub enum DateTimeError {
/// Invalid date format.
InvalidFormat,
/// Invalid timezone.
InvalidTimezone,
}

impl fmt::Display for DateTimeError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
DateTimeError::InvalidFormat => {
write!(f, "Invalid date format")
}
DateTimeError::InvalidTimezone => {
write!(f, "Invalid timezone")
}
}
}
}

impl Error for DateTimeError {}

///
/// DateTime struct to ease dates and times manipulation.
///
Expand Down Expand Up @@ -202,30 +226,6 @@ pub struct DateTime {
pub year: i32,
}

/// Custom error type for DateTime parsing.
#[derive(Debug)]
pub enum DateTimeError {
/// Invalid date format.
InvalidFormat,
/// Invalid timezone.
InvalidTimezone,
}

impl fmt::Display for DateTimeError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
DateTimeError::InvalidFormat => {
write!(f, "Invalid date format")
}
DateTimeError::InvalidTimezone => {
write!(f, "Invalid timezone")
}
}
}
}

impl Error for DateTimeError {}

impl DateTime {
/// Parse the input string and create a new `DateTime` object.
///
Expand Down

0 comments on commit f472d17

Please sign in to comment.