From 488f1016188ff256247ec9241ff55da305b58c68 Mon Sep 17 00:00:00 2001 From: Palash Tyagi <23239946+Magnus167@users.noreply.github.com> Date: Mon, 21 Apr 2025 01:27:28 +0100 Subject: [PATCH 1/2] Update module exports to include BDatesGenerator and DatesGenerator --- src/utils/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 7c832f6..384c2ca 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -1,6 +1,6 @@ pub mod bdates; -pub use bdates::{BDateFreq, BDatesList}; +pub use bdates::{BDateFreq, BDatesList, BDatesGenerator}; pub mod dates; -pub use dates::{DateFreq, DatesList}; +pub use dates::{DateFreq, DatesList, DatesGenerator}; From 25e3405d8560b8d94a48571544c07fe55c713c5b Mon Sep 17 00:00:00 2001 From: Palash Tyagi <23239946+Magnus167@users.noreply.github.com> Date: Mon, 21 Apr 2025 01:27:41 +0100 Subject: [PATCH 2/2] Update documentation to use rustframe::utils for BDatesList and DatesList --- src/utils/bdates.rs | 40 ++++++++++++++++++++-------------------- src/utils/dates.rs | 39 +++++++++++++++++++-------------------- 2 files changed, 39 insertions(+), 40 deletions(-) diff --git a/src/utils/bdates.rs b/src/utils/bdates.rs index ae76476..4664d0f 100644 --- a/src/utils/bdates.rs +++ b/src/utils/bdates.rs @@ -165,9 +165,9 @@ enum GroupKey { /// ```rust /// use chrono::NaiveDate; /// use std::error::Error; -/// # use bdates::{BDatesList, BDateFreq}; // Replace bdates with your actual crate/module name +/// use rustframe::utils::{BDatesList, BDateFreq}; // Replace bdates with your actual crate/module name /// -/// # fn main() -> Result<(), Box> { +/// fn main() -> Result<(), Box> { /// let start_date = "2023-11-01".to_string(); // Wednesday /// let end_date = "2023-11-07".to_string(); // Tuesday /// let freq = BDateFreq::Daily; @@ -184,8 +184,8 @@ enum GroupKey { /// /// assert_eq!(bdates.list()?, expected_dates); /// assert_eq!(bdates.count()?, 5); -/// # Ok(()) -/// # } +/// Ok(()) +/// } /// ``` /// /// **2. Using `from_n_periods` (Start Date and Count):** @@ -193,9 +193,9 @@ enum GroupKey { /// ```rust /// use chrono::NaiveDate; /// use std::error::Error; -/// # use bdates::{BDatesList, BDateFreq}; // Replace bdates with your actual crate/module name +/// use rustframe::utils::{BDatesList, BDateFreq}; // Replace bdates with your actual crate/module name /// -/// # fn main() -> Result<(), Box> { +/// fn main() -> Result<(), Box> { /// let start_date = "2024-02-28".to_string(); // Wednesday /// let freq = BDateFreq::WeeklyFriday; /// let n_periods = 3; @@ -214,8 +214,8 @@ enum GroupKey { /// assert_eq!(bdates.count()?, 3); /// assert_eq!(bdates.start_date_str(), "2024-02-28"); // Keeps original start string /// assert_eq!(bdates.end_date_str(), "2024-03-15"); // End date is the last generated date -/// # Ok(()) -/// # } +/// Ok(()) +/// } /// ``` /// /// **3. Using `groups()`:** @@ -223,9 +223,9 @@ enum GroupKey { /// ```rust /// use chrono::NaiveDate; /// use std::error::Error; -/// # use bdates::{BDatesList, BDateFreq}; // Replace bdates with your actual crate/module name +/// use rustframe::utils::{BDatesList, BDateFreq}; // Replace bdates with your actual crate/module name /// -/// # fn main() -> Result<(), Box> { +/// fn main() -> Result<(), Box> { /// let start_date = "2023-11-20".to_string(); // Mon, Week 47 /// let end_date = "2023-12-08".to_string(); // Fri, Week 49 /// let freq = BDateFreq::WeeklyMonday; @@ -239,8 +239,8 @@ enum GroupKey { /// assert_eq!(groups[0], vec![NaiveDate::from_ymd_opt(2023, 11, 20).unwrap()]); // Week 47 /// assert_eq!(groups[1], vec![NaiveDate::from_ymd_opt(2023, 11, 27).unwrap()]); // Week 48 /// assert_eq!(groups[2], vec![NaiveDate::from_ymd_opt(2023, 12, 4).unwrap()]); // Week 49 -/// # Ok(()) -/// # } +/// Ok(()) +/// } /// ``` impl BDatesList { /// Creates a new `BDatesList` instance defined by a start and end date. @@ -451,9 +451,9 @@ impl BDatesList { /// ```rust /// use chrono::NaiveDate; /// use std::error::Error; -/// # use bdates::{BDatesGenerator, BDateFreq}; // Replace bdates with your actual crate/module name +/// use rustframe::utils::{BDatesGenerator, BDateFreq}; /// -/// # fn main() -> Result<(), Box> { +/// fn main() -> Result<(), Box> { /// let start = NaiveDate::from_ymd_opt(2023, 12, 28).unwrap(); // Thursday /// let freq = BDateFreq::MonthEnd; /// let n_periods = 4; // Dec '23, Jan '24, Feb '24, Mar '24 @@ -466,8 +466,8 @@ impl BDatesList { /// assert_eq!(generator.next(), Some(NaiveDate::from_ymd_opt(2024, 2, 29).unwrap())); // Leap year /// assert_eq!(generator.next(), Some(NaiveDate::from_ymd_opt(2024, 3, 29).unwrap())); // Mar 31 is Sun /// assert_eq!(generator.next(), None); // Exhausted -/// # Ok(()) -/// # } +/// Ok(()) +/// } /// ``` /// /// **2. Collecting into a Vec:** @@ -475,9 +475,9 @@ impl BDatesList { /// ```rust /// use chrono::NaiveDate; /// use std::error::Error; -/// # use bdates::{BDatesGenerator, BDateFreq}; // Replace bdates with your actual crate/module name +/// use rustframe::utils::{BDatesGenerator, BDateFreq}; // Replace bdates with your actual crate/module name /// -/// # fn main() -> Result<(), Box> { +/// fn main() -> Result<(), Box> { /// let start = NaiveDate::from_ymd_opt(2024, 4, 29).unwrap(); // Monday /// let freq = BDateFreq::Daily; /// let n_periods = 5; @@ -494,8 +494,8 @@ impl BDatesList { /// ]; /// /// assert_eq!(dates, expected_dates); -/// # Ok(()) -/// # } +/// Ok(()) +/// } /// ``` #[derive(Debug, Clone)] pub struct BDatesGenerator { diff --git a/src/utils/dates.rs b/src/utils/dates.rs index 779b469..e2bcf3c 100644 --- a/src/utils/dates.rs +++ b/src/utils/dates.rs @@ -164,7 +164,7 @@ enum GroupKey { /// ```rust /// use chrono::NaiveDate; /// use std::error::Error; -/// # use dates::{DatesList, DateFreq}; // Assuming the crate/module is named 'dates' +/// # use rustframe::utils::{DatesList, DateFreq}; // Assuming the crate/module is named 'dates' /// /// # fn main() -> Result<(), Box> { /// let start_date = "2023-11-01".to_string(); // Wednesday @@ -194,9 +194,9 @@ enum GroupKey { /// ```rust /// use chrono::NaiveDate; /// use std::error::Error; -/// # use dates::{DatesList, DateFreq}; +/// use rustframe::utils::{DatesList, DateFreq}; /// -/// # fn main() -> Result<(), Box> { +/// fn main() -> Result<(), Box> { /// let start_date = "2024-02-28".to_string(); // Wednesday /// let freq = DateFreq::WeeklyFriday; /// let n_periods = 3; @@ -224,9 +224,9 @@ enum GroupKey { /// ```rust /// use chrono::NaiveDate; /// use std::error::Error; -/// # use dates::{DatesList, DateFreq}; +/// use rustframe::utils::{DatesList, DateFreq}; /// -/// # fn main() -> Result<(), Box> { +/// fn main() -> Result<(), Box> { /// let start_date = "2023-11-20".to_string(); // Mon, Week 47 /// let end_date = "2023-12-08".to_string(); // Fri, Week 49 /// let freq = DateFreq::MonthEnd; // Find month-ends @@ -238,8 +238,8 @@ enum GroupKey { /// /// assert_eq!(groups.len(), 1); // Only November's end date falls in the range /// assert_eq!(groups[0], vec![NaiveDate::from_ymd_opt(2023, 11, 30).unwrap()]); // Nov 2023 group -/// # Ok(()) -/// # } +/// Ok(()) +/// } /// ``` impl DatesList { /// Creates a new `DatesList` instance defined by a start and end date. @@ -422,10 +422,9 @@ impl DatesList { /// ```rust /// use chrono::NaiveDate; /// use std::error::Error; -/// # // Replace 'your_crate_name' with the actual name if this is in a library -/// # use dates::{DatesGenerator, DateFreq}; +/// use rustframe::utils::{DatesGenerator, DateFreq}; /// -/// # fn main() -> Result<(), Box> { +/// fn main() -> Result<(), Box> { /// let start = NaiveDate::from_ymd_opt(2023, 12, 28).unwrap(); // Thursday /// let freq = DateFreq::MonthEnd; /// let n_periods = 4; // Dec '23, Jan '24, Feb '24, Mar '24 @@ -438,8 +437,8 @@ impl DatesList { /// assert_eq!(generator.next(), Some(NaiveDate::from_ymd_opt(2024, 2, 29).unwrap())); // Leap year /// assert_eq!(generator.next(), Some(NaiveDate::from_ymd_opt(2024, 3, 31).unwrap())); /// assert_eq!(generator.next(), None); // Exhausted -/// # Ok(()) -/// # } +/// Ok(()) +/// } /// ``` /// /// **2. Collecting into a Vec (Daily):** @@ -447,9 +446,9 @@ impl DatesList { /// ```rust /// use chrono::NaiveDate; /// use std::error::Error; -/// # use dates::{DatesGenerator, DateFreq}; +/// use rustframe::utils::{DatesGenerator, DateFreq}; /// -/// # fn main() -> Result<(), Box> { +/// fn main() -> Result<(), Box> { /// let start = NaiveDate::from_ymd_opt(2024, 4, 29).unwrap(); // Monday /// let freq = DateFreq::Daily; /// let n_periods = 5; @@ -466,8 +465,8 @@ impl DatesList { /// ]; /// /// assert_eq!(dates, expected_dates); -/// # Ok(()) -/// # } +/// Ok(()) +/// } /// ``` /// /// **3. Starting on the Exact Day (Weekly Monday):** @@ -475,9 +474,9 @@ impl DatesList { /// ```rust /// use chrono::NaiveDate; /// use std::error::Error; -/// # use dates::{DatesGenerator, DateFreq}; +/// use rustframe::utils::{DatesGenerator, DateFreq}; /// -/// # fn main() -> Result<(), Box> { +/// fn main() -> Result<(), Box> { /// let start = NaiveDate::from_ymd_opt(2024, 1, 1).unwrap(); // Monday /// let freq = DateFreq::WeeklyMonday; /// let n_periods = 3; @@ -488,8 +487,8 @@ impl DatesList { /// assert_eq!(generator.next(), Some(NaiveDate::from_ymd_opt(2024, 1, 8).unwrap())); /// assert_eq!(generator.next(), Some(NaiveDate::from_ymd_opt(2024, 1, 15).unwrap())); /// assert_eq!(generator.next(), None); -/// # Ok(()) -/// # } +/// Ok(()) +/// } /// ``` #[derive(Debug, Clone)] pub struct DatesGenerator {